Baton - minimalist inter-thread notification
Summary: A Baton allows a thread to block once and be awoken: it captures a single handoff. During its lifecycle (from construction/reset to destruction/reset) a baton must either be post()ed and wait()ed exactly once each, or not at all. Batons may be reused after a call to recycle(). Baton includes no internal padding, and is only 4 bytes in size. Any alignment or padding to avoid false sharing is up to the user. This is basically a stripped-down semaphore that supports only a single call to sem_post. The current posix semaphore sem_t isn't too bad, but this provides more a bit more speed, checking, inlining, smaller size, a guarantee that the implementation won't change, and compatibility with DeterministicSchedule. Baton is directly implemented on top of futex, and takes care to avoid system calls. Test Plan: 1. new unit tests 2. this code has already been in production use in TAO for many months Reviewed By: davejwatson@fb.com FB internal diff: D1130407
Showing
folly/Baton.h
0 → 100644
folly/test/BatonTest.cpp
0 → 100644
Please register or sign in to comment