User: Password:
|
|
Subscribe / Log in / New account

The kevent interface

The kevent interface

Posted Mar 3, 2006 6:20 UTC (Fri) by theraphim (subscriber, #25955)
Parent article: The kevent interface

Some time ago I've tried to write some multithreaded server which operates on filedescriptors and timeouts.
So, each thread running one processing loop
while (wait_for_event_on_fd_or_timeout(...)) { ... }

While filedescriptors are actually sockets (and it's obvious what to do with them) timeouts is a queue of events. While processing some other event in some other thread there might be need to add or remove timeout. And it can land on top of the heap or sink lower.

The only way I found to do this without any event-like objects is - add one end of pipe to epoll fd of wait_... and dedicate additional thread for timeout management. When timeout occurs, just write 1 char to pipe (and some thread will definitely wake up).


(Log in to post comments)


Copyright © 2018, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds