简体   繁体   中英

How can I use a Condvar with a RwLock?

I have several threads waiting on the same Condvar associated with data wrapped inside a RwLock . I'd like to call Condvar::wait and check a condition after holding the write lock to the data, but it seems Condvar::wait only accepts MutexGuard as an argument. Since there are many other parts that use this data as a read-only variable, I can't simply replace RwLock with Mutex .

How should I use Condvar together with RwLock -wrapped data?

https://github.com/Amanieu/parking_lot/issues/165用于使用的示例CondVarRwLockGuard

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM