Commit 65fc07b5 authored by David Lam's avatar David Lam Committed by Facebook Github Bot

Fix Synchronized.md documentation to use correct condition_variable::wait call

Summary:
`condition_variable::wait_for` takes as second param `std::chrono::duration`
and not a predicate; what we want is `condition_variable::wait`.

Reviewed By: simpkins

Differential Revision: D4295305

fbshipit-source-id: 05f735fe6e7ecb9d8f42cb38a2985b9ce9dad984
parent 68112fa0
...@@ -366,7 +366,7 @@ This code does not have the same problem as the counter-example with ...@@ -366,7 +366,7 @@ This code does not have the same problem as the counter-example with
When using `Synchronized` with a shared mutex type, it provides separate When using `Synchronized` with a shared mutex type, it provides separate
`withWLock()` and `withRLock()` methods instead of `withLock()`. `withWLock()` and `withRLock()` methods instead of `withLock()`.
#### `ulock()` and `withULockPtr()` #### `ulock()` and `withULockPtr()`
`Synchronized` also supports upgrading and downgrading mutex lock levels as `Synchronized` also supports upgrading and downgrading mutex lock levels as
long as the mutex type used to instantiate the `Synchronized` type has the long as the mutex type used to instantiate the `Synchronized` type has the
...@@ -669,8 +669,8 @@ The `LockedPtr` returned by `Synchronized<T, std::mutex>::lock()` has a ...@@ -669,8 +669,8 @@ The `LockedPtr` returned by `Synchronized<T, std::mutex>::lock()` has a
// Assuming some other thread will put data on vec and signal // Assuming some other thread will put data on vec and signal
// emptySignal, we can then wait on it as follows: // emptySignal, we can then wait on it as follows:
auto locked = vec.lock(); auto locked = vec.lock();
emptySignal.wait_for(locked.getUniqueLock(), emptySignal.wait(locked.getUniqueLock(),
[&] { return !locked->empty(); }); [&] { return !locked->empty(); });
``` ```
### `acquireLocked()` ### `acquireLocked()`
...@@ -728,7 +728,7 @@ which will make the returned tuple more convenient to use: ...@@ -728,7 +728,7 @@ which will make the returned tuple more convenient to use:
An `acquireLockedPair()` function is also available, which returns a An `acquireLockedPair()` function is also available, which returns a
`std::pair` instead of a `std::tuple`. This is more convenient to use `std::pair` instead of a `std::tuple`. This is more convenient to use
in many situations, until compiler support for structured bindings is in many situations, until compiler support for structured bindings is
more widely available. more widely available.
### Synchronizing several data items with one mutex ### Synchronizing several data items with one mutex
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment