Thanks for the suggestions! I think the libev proposal from Mike looks closest to what I need. On Wed, Jun 6, 2012 at 12:15 PM, Coda Highland <chighland@xxxxxxxxx> wrote: > On Wed, Jun 6, 2012 at 2:06 PM, Tim Caswell <tim@xxxxxxxxxxxxxx> wrote: > > > > > > On Wed, Jun 6, 2012 at 1:59 PM, Mike Pall <mike-1206@xxxxxxxxxx> wrote: > >> > >> demetri wrote: > >> > I've done some digging and found Lua/C API based libraries, and > >> > obviously I > >> > could just bind specific functions myself, but I thought this was > >> > something > >> > that might be a "solved problem" in the LuaJIT community. > >> > >> If you don't mind it's wrapping libev (not libevent), here's one > >> from Evan Wies: > >> > >> https://gist.github.com/1409794 > >> > >> I didn't try it, but the code looks good. And this is in no way an > >> endorsement for libev vs. libevent (they all have their flaws, the > >> most obvious is requiring C callbacks). > > > > > > How else would you implement a non-blocking, single-threaded system > without > > C callbacks? I'm curious. Maybe bake in co-routines instead? > > The other control mechanism is to have event structs that you pick up > from a queue, perhaps with select() or something to signal when > there's something to collect. Callback-based systems use this scheme > internally and just associate each structure with a callback. You > could expose select() (or poll() or whatever) in the FFI to pick up on > these and then dispatch in Lua code. > > /s/ Adam > >