6 #include <sys/select.h>
20KernelEventMechanism::KernelEventMechanism() : initialized(false), _psd(NULL) {
32KernelEventMechanism::~KernelEventMechanism() {
60 bool haveInterest =
false;
74 if (haveInterest ==
true) {
80 psd->fdsMutex.unlock();
108 struct timeval timeout = {0, 1L * 1000L};
112 fd_set rfds = psd->rfds;
113 fd_set wfds = psd->wfds;
114 psd->fdsMutex.unlock();
117 auto result = select(psd->maxFd + 1, &rfds, &wfds, NULL, &timeout);
123 psd->fdsMutex.lock();
125 for (
auto fdIt = psd->fds.begin(); fdIt != psd->fds.end(); ++fdIt) {
126 if (FD_ISSET(fdIt->first, &rfds) != 0) {
127 KernelEventMechanismPSD::Event event;
128 event.descriptor = fdIt->first;
130 event.cookie = fdIt->second;
131 psd->events.push_back(event);
133 if (FD_ISSET(fdIt->first, &wfds) != 0) {
134 KernelEventMechanismPSD::Event event;
135 event.descriptor = fdIt->first;
137 event.cookie = fdIt->second;
138 psd->events.push_back(event);
141 psd->fdsMutex.unlock();
144 return psd->events.size();
155 KernelEventMechanismPSD::Event&
event = psd->
events[index];
156 interest =
event.interest;
157 cookie =
event.cookie;
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.
void lock()
Locks the mutex, additionally mutex locks will block until other locks have been unlocked.
const NIOInterest NIO_INTEREST_READ
uint8_t NIOInterest
type definiton for network UI interest
const NIOInterest NIO_INTEREST_WRITE