How to unlock a rwlock? I can't drop the lock since i need it more than 1 time. I have some code like this:
struct Abc {
lock: RwLock<()>,
data: usize,
}
let a = Abc {
RwLock::new(()),
data: 0,
};
a.lock.read().unwrap();
// do something with data
// now i need to unlock a.lock so others threads can use it
As @Michael Anderson said, the RwLock is unlocked when the guards is dropped, not the RwLock itself.
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.