-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathEPollRunLoop.hpp
More file actions
41 lines (28 loc) · 993 Bytes
/
EPollRunLoop.hpp
File metadata and controls
41 lines (28 loc) · 993 Bytes
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
39
40
41
#pragma once
// Copyright © 2022 Michael Thornburgh
// SPDX-License-Identifier: MIT
#include <map>
#include <thread>
#include <queue>
#include "RunLoop.hpp"
namespace com { namespace zenomt {
class EPollRunLoop : public RunLoop {
public:
EPollRunLoop(bool sharedTimeOrigin = false);
~EPollRunLoop();
using RunLoop::registerDescriptor;
using RunLoop::unregisterDescriptor;
void registerDescriptor(int fd, Condition cond, const Action &action) override;
void unregisterDescriptor(int fd, Condition cond) override;
void run(Duration runInterval = INFINITY, Duration minSleep = 0) override;
bool isRunningInThisThread() const override;
void clear() override;
protected:
struct Descriptor;
struct DescriptorItem;
void processActivatedItems(std::queue<std::shared_ptr<DescriptorItem>> &activatedItems, Condition cond);
int m_epoll;
std::map<int, std::shared_ptr<Descriptor>> m_descriptors;
std::atomic<std::thread::id> m_runningInThread;
};
} } // namespace com::zenomt