Bitcoin Core  27.99.0
P2P Digital Currency
task_runner.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_UTIL_TASK_RUNNER_H
6 #define BITCOIN_UTIL_TASK_RUNNER_H
7 
8 #include <cstddef>
9 #include <functional>
10 
11 namespace util {
12 
20 {
21 public:
22  virtual ~TaskRunnerInterface() {}
23 
29  virtual void insert(std::function<void()> func) = 0;
30 
34  virtual void flush() = 0;
35 
39  virtual size_t size() = 0;
40 };
41 
43 {
44 public:
45  void insert(std::function<void()> func) override { func(); }
46  void flush() override {}
47  size_t size() override { return 0; }
48 };
49 
50 } // namespace util
51 
52 #endif // BITCOIN_UTIL_TASK_RUNNER_H
size_t size() override
Returns the number of currently pending events.
Definition: task_runner.h:47
void insert(std::function< void()> func) override
The callback can either be queued for later/asynchronous/threaded processing, or be executed immediat...
Definition: task_runner.h:45
void flush() override
Forces the processing of all pending events.
Definition: task_runner.h:46
virtual size_t size()=0
Returns the number of currently pending events.
virtual void flush()=0
Forces the processing of all pending events.
virtual void insert(std::function< void()> func)=0
The callback can either be queued for later/asynchronous/threaded processing, or be executed immediat...
virtual ~TaskRunnerInterface()
Definition: task_runner.h:22