libcosmos
Linux C++ System Programming Library
Loading...
Searching...
No Matches
EventFile.hxx
1#pragma once
2
3// Linux
4#include <sys/eventfd.h>
5
6// cosmos
7#include <cosmos/BitMask.hxx>
8#include <cosmos/fs/FDFile.hxx>
9
10namespace cosmos {
11
13
41class COSMOS_API EventFile :
42 protected FDFile {
43public: // types
44
46 enum class Counter : uint64_t {};
47
48 enum class Flag : int {
49 CLOSE_ON_EXEC = EFD_CLOEXEC,
50 NONBLOCK = EFD_NONBLOCK,
51 SEMAPHORE = EFD_SEMAPHORE
52 };
53
54 using Flags = BitMask<Flag>;
55
56public: // functions
57
58 explicit EventFile(const Counter initval = Counter{0}, const Flags flags = Flags{Flag::CLOSE_ON_EXEC});
59
60 using FDFile::close;
61 using FileBase::fd;
62 using FileBase::isOpen;
63
65
76 Counter wait();
77
79
85 void signal(const Counter increment = Counter{1});
86};
87
88} // end ns
A typesafe bit mask representation using class enums.
Definition BitMask.hxx:19
Wrapper around an eventfd FileDescriptor.
Definition EventFile.hxx:42
Counter
Strong counter type used with the event fd.
Definition EventFile.hxx:46
File objects that are opened from existing FileDescriptor objects.
Definition FDFile.hxx:16
@ NONBLOCK
Attempt to open the file in non-blocking mode causing I/O operations not to block.