Coverage Report

Created: 2026-09-01 13:35

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/root/bitcoin/src/util/threadinterrupt.cpp
Line
Count
Source
1
// Copyright (c) 2009-2010 Satoshi Nakamoto
2
// Copyright (c) 2009-present 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
#include <sync.h>
9
10
8.64k
CThreadInterrupt::CThreadInterrupt() : flag(false) {}
11
12
bool CThreadInterrupt::interrupted() const
13
4.39k
{
14
4.39k
    return flag.load(std::memory_order_acquire);
15
4.39k
}
16
17
CThreadInterrupt::operator bool() const
18
52.0k
{
19
52.0k
    return interrupted();
20
52.0k
}
21
22
void CThreadInterrupt::reset()
23
189
{
24
189
    flag.store(false, std::memory_order_release);
25
189
}
26
27
void CThreadInterrupt::operator()()
28
12.5k
{
29
12.5k
    {
30
12.5k
        LOCK(mut);
31
12.5k
        flag.store(true, std::memory_order_release);
32
12.5k
    }
33
12.5k
    cond.notify_all();
34
12.5k
}
35
36
bool CThreadInterrupt::sleep_for(Clock::duration rel_time)
37
0
{
38
0
    WAIT_LOCK(mut, lock);
39
0
    return !cond.wait_for(lock, rel_time, [this]() { return flag.load(std::memory_order_acquire); });
40
0
}