lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

Hello list,

I've been meaning to write a new event library for a while, but I
thought I'd throw the idea at the list first to see if it has merit.

Basically, I want to create an event library for Lua that sits on top
of another event library (luaevent for now, but I would probably make
the system flexible enough for a different library should that be
desired).  It would provide a simpler interface for events, so you could
do something like this:

    local w = ev:timer {
      interval = 1,
      callback = function()
        print 'One second has passed!'

However, that part is just the gravy.  The point of doing a whole new
library would be to make the entire thing coroutine-based.  Think of it
like Copas, but applied to generic events instead of just TCP/IP
sockets.  So let's say I wanted to print 'hello' a second after a user
clicked a button in a GUI.  I could do something like this:

  -- this assumes that the GUI plays nicely with the event loop
    print 'hi'

and other events would continue to fire while the button handler is
sleeping.  Also, you could write a timer-based event like this:

  while true do
    print 'waking up!'

The library would also provide other operations for waiting for an event
to happen.

So, what do you all think?  Does this idea sound cool to you too, or
does it sound useless/dumb/too magical/etc?