Add Baton variants with multiple posters and with a non-blocking waiter
authorMaged Michael <magedmichael@fb.com>
Fri, 17 Feb 2017 13:13:28 +0000 (05:13 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 17 Feb 2017 13:21:19 +0000 (05:21 -0800)
commitf795d501ba155f3fac9ed8bec40cbbc8eb4045ad
tree8b921918d2ee6a860cb35ef04b9ed21bf9813f67
parent05499631dc3e1160d673a7dd57e70fc797e532dc
Add Baton variants with multiple posters and with a non-blocking waiter

Summary:
Added two variants of Baton by adding two Boolean template parameters with defaults that correspond to the original single poster blocking waiter version:
- SinglePoster (single poster vs multiple posters). Default true.
- Blocking (vs spinning). Default true.

The multi-poster baton (SinglePoster = false) can be handed over by multiple concurrent posters, where redundant post()-s are idempotent but if a post() arrives after the baton is reset() then it unblocks the waiter.

The nonblocking Baton (Blocking = false) has faster common case post(), by avoiding CAS in the critical path. It does so by disallowing waiter blocking and timed_wait().

Reviewed By: nbronson

Differential Revision: D4506728

fbshipit-source-id: e5b65ad93e443fbba22164319c985ebc8424554a
folly/Baton.h
folly/test/BatonBenchmark.cpp
folly/test/BatonTest.cpp
folly/test/BatonTestHelpers.h