Bitcoin ABC  0.26.3
P2P Digital Currency
threadinterrupt.h
Go to the documentation of this file.
1 // Copyright (c) 2016 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_THREADINTERRUPT_H
6 #define BITCOIN_THREADINTERRUPT_H
7 
8 #include <sync.h>
9 
10 #include <atomic>
11 #include <chrono>
12 #include <condition_variable>
13 
20 public:
22  explicit operator bool() const;
24  void reset();
25  bool sleep_for(std::chrono::milliseconds rel_time)
27  bool sleep_for(std::chrono::seconds rel_time)
29  bool sleep_for(std::chrono::minutes rel_time)
31 
32 private:
33  std::condition_variable cond;
35  std::atomic<bool> flag;
36 };
37 
38 #endif // BITCOIN_THREADINTERRUPT_H
A helper class for interruptible sleeps.
void operator()() EXCLUSIVE_LOCKS_REQUIRED(!mut)
std::atomic< bool > flag
bool sleep_for(std::chrono::milliseconds rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut)
std::condition_variable cond
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:56