22KernelEventMechanism::KernelEventMechanism() : initialized(false), _psd(NULL) {
27KernelEventMechanism::~KernelEventMechanism() {
37 struct epoll_event event;
38 event.events = EPOLLET;
39 event.data.ptr = (
void*)cookie;
43 event.events|= EPOLLIN;
47 event.events|= EPOLLOUT;
57 std::string msg =
"Could not add epoll event: ";
58 msg+= strerror(errno);
69 psd->epEventList =
new epoll_event[psd->epEventListMax];
72 psd->ep = epoll_create1(0);
74 delete [] psd->epEventList;
75 std::string msg =
"Could not create epoll: ";
76 msg+= strerror(errno);
93 delete [] psd->epEventList;
100 while (
true ==
true) {
102 auto events = epoll_wait(psd->ep, psd->epEventList, psd->epEventListMax, 5);
106 if (errno == EINTR) {
109 std::string msg =
"epoll_wait failed: ";
110 msg+= strerror(errno);
128 cookie = (
void*)event->data.ptr;
132 if ((event->events & EPOLLIN) == EPOLLIN) {
135 if ((event->events & EPOLLOUT) == EPOLLOUT) {
Interface to kernel event mechanismns.
void shutdownKernelEventMechanism()
shutdowns the kernel event mechanism
void setSocketInterest(const NetworkSocket &socket, const NIOInterest lastInterest, const NIOInterest interest, const void *cookie)
sets a non blocked socket io interest
int doKernelEventMechanism()
do the kernel event mechanism
void initKernelEventMechanism(const unsigned int maxCCU)
initializes the kernel event mechanism
void decodeKernelEvent(const unsigned int index, NIOInterest &interest, void *&cookie)
decodes a kernel event
Kernel event mechanism exception class.
Base class of network sockets.
const NIOInterest NIO_INTEREST_NONE
const NIOInterest NIO_INTEREST_READ
uint8_t NIOInterest
type definiton for network UI interest
const NIOInterest NIO_INTEREST_WRITE