Bitcoin Core  31.0.0
P2P Digital Currency
threadinterrupt.h
Go to the documentation of this file.
1 // Copyright (c) 2024-present 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_TEST_FUZZ_UTIL_THREADINTERRUPT_H
6 #define BITCOIN_TEST_FUZZ_UTIL_THREADINTERRUPT_H
7 
9 #include <util/threadinterrupt.h>
10 
11 #include <memory>
12 
17 {
18 public:
20 
21  virtual bool interrupted() const override;
22  virtual bool sleep_for(Clock::duration) override;
23 
24 private:
26 };
27 
28 [[nodiscard]] inline std::shared_ptr<CThreadInterrupt> ConsumeThreadInterrupt(FuzzedDataProvider& fuzzed_data_provider)
29 {
30  return std::make_shared<FuzzedThreadInterrupt>(fuzzed_data_provider);
31 }
32 
33 #endif // BITCOIN_TEST_FUZZ_UTIL_THREADINTERRUPT_H
virtual bool interrupted() const override
Return true if operator()() has been called.
FuzzedThreadInterrupt(FuzzedDataProvider &fuzzed_data_provider)
virtual bool sleep_for(Clock::duration) override
Sleep for the given duration.
A helper class for interruptible sleeps.
Mocked CThreadInterrupt that returns "randomly" whether it is interrupted and never sleeps...
FuzzedDataProvider & fuzzed_data_provider
Definition: fees.cpp:38
std::shared_ptr< CThreadInterrupt > ConsumeThreadInterrupt(FuzzedDataProvider &fuzzed_data_provider)
FuzzedDataProvider & m_fuzzed_data_provider