dfx 0.1.0
Linux-based dynamic dataflow executor
Loading...
Searching...
No Matches
Events.hpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: 2025 Vincent Leroy
2// SPDX-License-Identifier: MIT
3//
4// This file is part of dfx.
5//
6// Licensed under the MIT License. See the LICENSE file in the project root
7// for full license information.
8
9#pragma once
10
11// Project includes
14#include <dfx-utilities/Join.hpp>
15
30
31namespace dfx::FdWatch
32{
42 enum class EventInterest
43 {
44 Read = 0x01,
45 Write = 0x02,
46 ReadClose = 0x04,
47
48 OneShot = 0x08,
49 };
50
53
66 enum class EventTrigger
67 {
68 Readable = 0x01,
69 Writable = 0x02,
70 PeerClosed = 0x04,
71 Hangup = 0x08,
72 Error = 0x10,
73 };
74
77
82 uint32_t toNativeEPollEvent(EventInterests events) noexcept;
87 EventTriggers fromNativeEPollEvent(uint32_t events) noexcept;
88} // !namespace dfx::FdWatch
89
90DECLARE_OPERATOR_FOR_FLAGS(dfx::FdWatch::EventInterests)
91DECLARE_OPERATOR_FOR_FLAGS(dfx::FdWatch::EventTriggers)
92
95
96DECLARE_STD_FORMATTER_FOR_FLAGS(dfx::FdWatch::EventInterests);
97DECLARE_STD_FORMATTER_FOR_FLAGS(dfx::FdWatch::EventTriggers);
Macro-based enum <-> string utilities for dfx.
#define DECLARE_ENUM_STRING_FUNCTIONS(E)
Declare the enum string API (and std::formatter) for enum type E.
Definition EnumString.hpp:327
Typesafe enum bitmask wrapper and helper macros.
#define DECLARE_OPERATOR_FOR_FLAGS(FlagsName)
Declare a free operator| to combine two enum values into a Flags.
Definition Flags.hpp:291
#define DECLARE_STD_FORMATTER_FOR_FLAGS(FlagsName)
Declare a std::formatter<FlagsName> that prints set flags joined by |.
Definition Flags.hpp:308
#define DECLARE_FLAGS(FlagsName, Enum)
Declare a convenient alias for dfx::Utils::Flags<Enum>.
Definition Flags.hpp:275
Bitset wrapper for dfx::FdWatch::EventInterest values.
Bitset wrapper for dfx::FdWatch::EventTrigger values.
Definition SocketClient.hpp:23
EventTriggers fromNativeEPollEvent(uint32_t events) noexcept
Convert a native epoll events bitmask into abstract triggers.
uint32_t toNativeEPollEvent(EventInterests events) noexcept
Convert abstract interests into a native epoll events bitmask.
EventInterest
Event types a watcher can subscribe to for a given file descriptor.
Definition Events.hpp:43
@ Write
Monitor writability (edge-triggered).
Definition Events.hpp:45
@ Read
Monitor readability (edge-triggered).
Definition Events.hpp:44
@ OneShot
One-shot behavior: guarantee a single notification between explicit re-arms.
Definition Events.hpp:48
@ ReadClose
Monitor peer shutdown / read-side closure (e.g. EPOLLRDHUP).
Definition Events.hpp:46
EventTrigger
Event types that can be delivered by the poller for a given file descriptor.
Definition Events.hpp:67
@ Readable
FD became readable (only if EventInterest::Read is set).
Definition Events.hpp:68
@ Hangup
Hangup detected (always delivered when observed).
Definition Events.hpp:71
@ Error
Error condition detected (always delivered when observed).
Definition Events.hpp:72
@ Writable
FD became writable (only if EventInterest::Write is set).
Definition Events.hpp:69
@ PeerClosed
Peer closed its write side / read-side hangup (only if EventInterest::ReadClose is set).
Definition Events.hpp:70