Saturating semaphore
authorMaged Michael <magedmichael@fb.com>
Thu, 30 Nov 2017 05:12:16 +0000 (21:12 -0800)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Thu, 30 Nov 2017 05:20:26 +0000 (21:20 -0800)
commit644a73aada5984d2c125d505a21a00174ba4f185
tree56ebc60f7a9d4964de0359de8ac4ede18d8aab24
parent614eb71734a284e1a9fefabcc48743a3c8efd653
Saturating semaphore

Summary:
SaturatingSemaphore is a flag that allows:
- multiple concurrent posters
- multiple concurrent waiters
- idempotent posting
- non-destructive waiting
- blocking and spinning
- pre-block spin time control

```
/// SaturatingSemaphore is a flag that allows concurrent posting by
/// multiple posters and concurrent non-destructive waiting by
/// multiple waiters.
///
/// A SaturatingSemaphore allows one or more waiter threads to check,
/// spin, or block, indefinitely or with timeout, for a flag to be set
/// by one or more poster threads. By setting the flag, posters
/// announce to waiters (that may be already waiting or will check
/// the flag in the future) that some condition is true. Posts to an
/// already set flag are idempotent.
```

Reviewed By: djwatson

Differential Revision: D6379704

fbshipit-source-id: 59aed76caa2d159639e75425a778a9c63f18f375
folly/synchronization/SaturatingSemaphore.h [new file with mode: 0644]
folly/synchronization/test/SaturatingSemaphoreTest.cpp [new file with mode: 0644]