diff options
author | fanquake <fanquake@gmail.com> | 2022-10-11 15:33:22 +0800 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2022-11-01 10:14:49 +0000 |
commit | b89530483d39f6a6a777df590b87ba2fad8c8b60 (patch) | |
tree | 76db063ca13d758a6b34220af362fc1ef85c6e95 /src/threadinterrupt.h | |
parent | c041d8f2c950105cbba1a1280321ffb7f48316da (diff) | |
download | bitcoin-b89530483d39f6a6a777df590b87ba2fad8c8b60.tar.xz |
util: move threadinterrupt into util
Diffstat (limited to 'src/threadinterrupt.h')
-rw-r--r-- | src/threadinterrupt.h | 36 |
1 files changed, 0 insertions, 36 deletions
diff --git a/src/threadinterrupt.h b/src/threadinterrupt.h deleted file mode 100644 index 979bc2ee3e..0000000000 --- a/src/threadinterrupt.h +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright (c) 2016-2021 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_THREADINTERRUPT_H -#define BITCOIN_THREADINTERRUPT_H - -#include <sync.h> -#include <threadsafety.h> - -#include <atomic> -#include <chrono> -#include <condition_variable> - -/* - A helper class for interruptible sleeps. Calling operator() will interrupt - any current sleep, and after that point operator bool() will return true - until reset. -*/ -class CThreadInterrupt -{ -public: - using Clock = std::chrono::steady_clock; - CThreadInterrupt(); - explicit operator bool() const; - void operator()() EXCLUSIVE_LOCKS_REQUIRED(!mut); - void reset(); - bool sleep_for(Clock::duration rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut); - -private: - std::condition_variable cond; - Mutex mut; - std::atomic<bool> flag; -}; - -#endif // BITCOIN_THREADINTERRUPT_H |