halayli/lthread

ability to poll on an fd without reading from it

Closed this issue · 3 comments

This is needed to integrate other event-driven-capable libraries like libzmq or libcurl. They expect to be woken up whenever certain fds become readable/writable, but they expect to be the ones doing the actual reading/writing.

I was able to get this to work by making _lthread_sched_event() public, and for example calling _lthread_sched_event(lthread_current(), fd, LT_EV_READ, 0) to wait until an fd becomes readable.

Would be nice to see some kind of solution in the public API. Libtask has fdwait() for this purpose.

IMO this is a duplicate of #23.

Yes, if a generic multi-fd poll method is acceptable, then this issue is redundant.

Fixed. Introduced lthread_wait_read(fd) and lthread_wait_write(fd) although they aren't documented yet.