]> Git Repo - VerusCoin.git/blob - src/reverselock.h
Incorporate all Zcash updates through 2.0.7-3 in addition to PBaaS, reserves, etc.
[VerusCoin.git] / src / reverselock.h
1 // Copyright (c) 2015 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or https://www.opensource.org/licenses/mit-license.php .
4
5 #ifndef BITCOIN_REVERSELOCK_H
6 #define BITCOIN_REVERSELOCK_H
7
8 /**
9  * An RAII-style reverse lock. Unlocks on construction and locks on destruction.
10  */
11 template<typename Lock>
12 class reverse_lock
13 {
14 public:
15
16     explicit reverse_lock(Lock& lock) : lock(lock) {
17         lock.unlock();
18         lock.swap(templock);
19     }
20
21     ~reverse_lock() {
22         templock.lock();
23         templock.swap(lock);
24     }
25
26 private:
27     reverse_lock(reverse_lock const&);
28     reverse_lock& operator=(reverse_lock const&);
29
30     Lock& lock;
31     Lock templock;
32 };
33
34 #endif // BITCOIN_REVERSELOCK_H
This page took 0.025744 seconds and 4 git commands to generate.