Skip to content

Commit 0dbf5a6

Browse files
author
Stjepan Glavina
committed
Add Drop impl for Mutex
1 parent f28e3c6 commit 0dbf5a6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

examples/mutex.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,13 @@ impl<T> Mutex<T> {
123123
}
124124
}
125125

126+
impl<T> Drop for MutexGuard<'_, T> {
127+
fn drop(&mut self) {
128+
self.0.locked.store(false, Ordering::Release);
129+
self.0.lock_ops.notify(1);
130+
}
131+
}
132+
126133
/// A guard holding a lock.
127134
struct MutexGuard<'a, T>(&'a Mutex<T>);
128135

0 commit comments

Comments
 (0)