bitcoin_sync/
scoped_raw_mutex.rs1crate::ix!();
2
3pub struct ScopedRawMutexGuard<'a> {
11
12 lock: &'a ScopedRawMutex,
13}
14
15impl<'a> ScopedRawMutexGuard<'a> {
16 pub fn new(x: &'a ScopedRawMutex) -> Self {
17 Self {
18 lock: x
19 }
20 }
21}
22
23impl<'a> Drop for ScopedRawMutexGuard<'a> {
24
25 fn drop(&mut self) {
26 unsafe { self.lock.0.unlock(); }
27 }
28}
29
30pub struct ScopedRawMutex(RawMutex);
32
33impl Default for ScopedRawMutex {
34
35 fn default() -> Self {
36 Self(RawMutex::INIT)
37 }
38}
39
40impl ScopedRawMutex {
41
42 pub fn lock(&self) -> ScopedRawMutexGuard<'_> {
43 self.0.lock();
44 ScopedRawMutexGuard::new(self)
45 }
46}