Standardize fiber baton behavior across threads and fibers
Summary: The behavior of fiber Baton is currently inconsistent around posting of a timed out baton, and subsequent calls to try_wait(). As stated in the post, only when the waiter is a thread will a post overwrite a timeout internally, and this is observable externally because try_wait returns true only if a baton is in the POSTED state, but not the timed out state. Example code: ``` folly::fibers::Baton b; b.try_wait_for(std::chrono::milliseconds(1)); b.try_wait(); // returns false b.post(); b.try_wait(); // Returns true on threads, false on fibers ``` Other options we could consider for the fix: * Update postThread to leave baton in a timeout state, and have waitThread move the baton into the timeout state on a failed wait. * Update try_wait() to return true if the state is either POSTED or TIMEOUT. Reviewed By: andriigrynenko Differential Revision: D14324532 fbshipit-source-id: 51b993a6153cba0fc3cf5701f765fff8ad1c8e3c
Showing
Please register or sign in to comment