forked from Bitcoin-ABC/bitcoin-abc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheventloop.h
38 lines (29 loc) · 870 Bytes
/
eventloop.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright (c) 2020 The Bitcoin developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#ifndef BITCOIN_EVENTLOOP_H
#define BITCOIN_EVENTLOOP_H
#include <sync.h>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <functional>
class CScheduler;
struct EventLoop {
public:
EventLoop() {}
~EventLoop();
bool startEventLoop(CScheduler &scheduler,
std::function<void()> runEventLoop,
std::chrono::milliseconds delta);
bool stopEventLoop();
private:
/**
* Start stop machinery.
*/
std::atomic<bool> stopRequest{false};
bool running GUARDED_BY(cs_running) = false;
Mutex cs_running;
std::condition_variable cond_running;
};
#endif // BITCOIN_EVENTLOOP_H