SNode.C
Loading...
Searching...
No Matches
EventMultiplexer.h
Go to the documentation of this file.
1/*
2 * SNode.C - a slim toolkit for network communication
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2020, 2021, 2022, 2023, 2024, 2025
5 *
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License as published
8 * by the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef CORE_POLL_EVENTDISPATCHER_H
21#define CORE_POLL_EVENTDISPATCHER_H
22
23#include "core/EventMultiplexer.h" // IWYU pragma: export
24
25namespace core {
27}
28
29#ifndef DOXYGEN_SHOULD_SKIP_THIS
30
31#include "core/system/poll.h" // IWYU pragma: export
32
33#include <unordered_map>
34#include <vector>
35
36#endif /* DOXYGEN_SHOULD_SKIP_THIS */
37
38namespace core::multiplexer::poll {
39
41 public:
42 struct PollFdIndex {
44 short events; // cppcheck-suppress unusedStructMember
45 };
46
47 explicit PollFdsManager();
48
49 void muxAdd(core::DescriptorEventReceiver* eventReceiver, short event);
50 void muxDel(int fd, short event);
51 void muxOn(const core::DescriptorEventReceiver* eventReceiver, short event);
52 void muxOff(const DescriptorEventReceiver* eventReceiver, short event);
53
55
56 const std::unordered_map<int, PollFdIndex>& getPollFdIndices() const;
57
58 nfds_t getCurrentSize() const;
59
60 private:
62 void compress();
63
66 };
67
68 class EventMultiplexer : public core::EventMultiplexer {
69 public:
71 ~EventMultiplexer() override = default;
72
73 private:
74 int monitorDescriptors(utils::Timeval& tickTimeOut, const sigset_t& sigMask) override;
75 void spanActiveEvents(int activeDescriptorCount) override;
76
78 };
79
80} // namespace core::multiplexer::poll
81
82#endif // CORE_POLL_EVENTDISPATCHER_H
core::multiplexer::poll::PollFdsManager & pollFds
DescriptorEventPublisher(const std::string &name, core::multiplexer::poll::PollFdsManager &pollFds, short events, short revents)
void muxOff(core::DescriptorEventReceiver *eventReceiver) override
void muxAdd(core::DescriptorEventReceiver *eventReceiver) override
void muxOn(core::DescriptorEventReceiver *eventReceiver) override
int monitorDescriptors(utils::Timeval &tickTimeOut, const sigset_t &sigMask) override
void spanActiveEvents(int activeDescriptorCount) override
void muxOff(const DescriptorEventReceiver *eventReceiver, short event)
void muxAdd(core::DescriptorEventReceiver *eventReceiver, short event)
const std::unordered_map< int, PollFdIndex > & getPollFdIndices() const
std::unordered_map< int, PollFdIndex > pollFdIndices
void muxOn(const core::DescriptorEventReceiver *eventReceiver, short event)