halayli / lthread

lthread, a multicore enabled coroutine library written in C
Other
814 stars 82 forks source link

ability to poll on an fd without reading from it #21

Closed jkarneges closed 10 years ago

jkarneges commented 10 years ago

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.

wisd0me commented 10 years ago

IMO this is a duplicate of #23.

jkarneges commented 10 years ago

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

halayli commented 10 years ago

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