bitcoinleveldb_sync/
mutexlock.rs

1/**
2  | Helper class that locks a mutex on construction
3  | and unlocks the mutex when the destructor
4  | of the MutexLock object is invoked.
5  | 
6  | Typical usage:
7  | 
8  | -----------
9  | @code
10  | 
11  | c_void MyClass::MyMethod() {
12  |   MutexLock l(&mu_);       // mu_ is an instance variable
13  |   ... some complex code, possibly with multiple return paths ...
14  | }
15  |
16  */
17
18crate::ix!();
19
20//-------------------------------------------[.cpp/bitcoin/src/leveldb/util/mutexlock.h]
21
22#[SCOPED_LOCKABLE]
23pub struct MutexLock {
24    mu: *const parking_lot::RawMutex,
25}
26
27impl Drop for MutexLock {
28
29    #[UNLOCK_FUNCTION()]
30    fn drop(&mut self) {
31        todo!();
32        /*
33            this->mu_->Unlock();
34        */
35    }
36}
37
38impl MutexLock {
39
40    #[EXCLUSIVE_LOCK_FUNCTION(mu)]
41    pub fn new(mu: *mut parking_lot::RawMutex) -> Self {
42    
43        todo!();
44        /*
45        : mu(mu),
46
47            this->mu_->Lock();
48        */
49    }
50}