Bitcoin ABC
0.34.3
P2P Digital Currency
Loading...
Searching...
No Matches
src
util
threadinterrupt.cpp
Go to the documentation of this file.
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-2016 The Bitcoin Core developers
3
// Distributed under the MIT software license, see the accompanying
4
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
5
6
#include <
util/threadinterrupt.h
>
7
8
CThreadInterrupt::CThreadInterrupt
() : flag(false) {}
9
10
CThreadInterrupt::operator bool()
const
{
11
return
flag.load(std::memory_order_acquire);
12
}
13
14
void
CThreadInterrupt::reset
() {
15
flag
.store(
false
, std::memory_order_release);
16
}
17
18
void
CThreadInterrupt::operator()
() {
19
{
20
LOCK
(
mut
);
21
flag
.store(
true
, std::memory_order_release);
22
}
23
cond
.notify_all();
24
}
25
26
bool
CThreadInterrupt::sleep_for
(Clock::duration rel_time) {
27
WAIT_LOCK
(
mut
, lock);
28
return
!
cond
.wait_for(lock, rel_time, [
this
]() {
29
return
flag
.load(std::memory_order_acquire);
30
});
31
}
CThreadInterrupt::operator()
void operator()() EXCLUSIVE_LOCKS_REQUIRED(!mut)
Definition
threadinterrupt.cpp:18
CThreadInterrupt::reset
void reset()
Definition
threadinterrupt.cpp:14
CThreadInterrupt::flag
std::atomic< bool > flag
Definition
threadinterrupt.h:38
CThreadInterrupt::mut
Mutex mut
Definition
threadinterrupt.h:37
CThreadInterrupt::sleep_for
bool sleep_for(Clock::duration rel_time) EXCLUSIVE_LOCKS_REQUIRED(!mut)
Definition
threadinterrupt.cpp:26
CThreadInterrupt::cond
std::condition_variable cond
Definition
threadinterrupt.h:36
CThreadInterrupt::CThreadInterrupt
CThreadInterrupt()
Definition
threadinterrupt.cpp:8
WAIT_LOCK
#define WAIT_LOCK(cs, name)
Definition
sync.h:304
LOCK
#define LOCK(cs)
Definition
sync.h:295
threadinterrupt.h
Generated on Thu Nov 5 2026 21:14:05 for Bitcoin ABC by
1.9.8