If you use a C library that requires callbacks, like libuv for instance, is it possible to write a procedure in chicken that will be guaranteed to return, as the C library requires? Like, by avoiding thread switching or call/cc or something?
I was thinking to sort of invert libuv, by using simple callbacks that only updated a global list of active event objects. The libuv main loop would return after a single event came in, and the scheme code could handle the events by checking that active list, and not have to worry about whether they're inside a persnickety C callback. Sort of like how epoll returns a list of active events, and libuv covers that up by dispatching those events to callbacks, and then I would use those callbacks to ...create a list of active events. Would I have to write those simple callbacks in C too? Could those simple C callbacks update a scheme "active event list" structure without getting longjmp'd? Or maybe the surrounding scheme would read a C structure "active" list? Come to think on it, epoll returns a list of active events, and doesn't IOCP also return a list of active events? I'm not much familiar with the Microsoft platform. I know Linux's async disk IO methods return a list of active events with no callbacks. (Then Glibc's AIO wraps them up in callbacks AND a thread pool -_-) Pretty sure kqueue doesn't use callbacks either. Most kernel developers are probably going to have a hard time doing anything with callbacks I imagine, since such callbacks would violate the kernel/userspace separation. Almost as if callbacks were a horrible idea in general... If so, I wish there was a cross platform networking library that used each platforms "fast" event poller, and simply produced a unified interface for events produced, instead of wrapping it up in registering callbacks and all that jazz. Can't think of a non-platform-specific events library that /doesn't/ use callbacks... _______________________________________________ Chicken-users mailing list [email protected] https://lists.nongnu.org/mailman/listinfo/chicken-users
