On Fri, 18 Mar 2016 05:04:25 GMT, denizzzka wrote:

On Thu, 06 Feb 2014 14:04:37 +0100, Sönke Ludwig wrote:

You need to have an existing FD (a socket of some kind) that is set to
non-blocking mode. You then create a FileDescriptorEvent and use
wait in the same situation that you'd normally use select to wait
for data:

auto evt = createFileDescriptorEvent(fd, FileDescriptorEvent.Trigger.any);

// read someting
while (true) {
   auto ret = recv(fd, but.ptr, buf.length, 0);
   if (ret < 0 && errno == EWOULDBLOCK) {
     // wait until data is available for read
     evt.wait(FileDescriptorEvent.Trigger.read);
   } else {
     // handle error or received data
   }
}

Just to make sure:

In this case there are will not created extra CPU thread for waiting socket event?

Events lib tracks events on the socket by the operating system functional (callbacks or something like from already existing OS thread)?

No, no new thread. In Linux it would typically use epoll_wait to wait for the next event within the same thread.