From: David Lam Date: Wed, 7 Dec 2016 23:32:30 +0000 (-0800) Subject: Fix Synchronized.md documentation to use correct condition_variable::wait call X-Git-Tag: v2016.12.12.00~8 X-Git-Url: http://plrg.eecs.uci.edu/git/?p=folly.git;a=commitdiff_plain;h=65fc07b5a8fe873663b3e7eb4486adb8d1688c92 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 --- diff --git a/folly/docs/Synchronized.md b/folly/docs/Synchronized.md index e65015a2..3d4bff0c 100644 --- a/folly/docs/Synchronized.md +++ b/folly/docs/Synchronized.md @@ -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 `withWLock()` and `withRLock()` methods instead of `withLock()`. -#### `ulock()` and `withULockPtr()` +#### `ulock()` and `withULockPtr()` `Synchronized` also supports upgrading and downgrading mutex lock levels as long as the mutex type used to instantiate the `Synchronized` type has the @@ -669,8 +669,8 @@ The `LockedPtr` returned by `Synchronized::lock()` has a // Assuming some other thread will put data on vec and signal // emptySignal, we can then wait on it as follows: auto locked = vec.lock(); - emptySignal.wait_for(locked.getUniqueLock(), - [&] { return !locked->empty(); }); + emptySignal.wait(locked.getUniqueLock(), + [&] { return !locked->empty(); }); ``` ### `acquireLocked()` @@ -728,7 +728,7 @@ which will make the returned tuple more convenient to use: An `acquireLockedPair()` function is also available, which returns a `std::pair` instead of a `std::tuple`. This is more convenient to use in many situations, until compiler support for structured bindings is -more widely available. +more widely available. ### Synchronizing several data items with one mutex