Re: Idea for an event loop library
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Idea for an event loop library
- From: Jorge <xxopxe@...>
- Date: 2012年5月10日 17:56:46 -0300
On mié, 2012年05月09日 at 07:22 -0400, Rob Hoelz wrote:
> 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).
For completeness sake: https://github.com/xopxe/Lumen
It does not depend on a event library, but on a library that provides a
select or poll-like call. At the moment, luasocket and nixio are
supported. It's of the "cooperative, events&blocking, coroutine based,
calculating the timeout for a select" class.
The API looks like this:
---------------------------------------------------
local sched = require "sched"
local emitter_task=sched.run(function()
sched.catalog.register('A')
while true do
sched.signal('ev', 'data!')
sched.sleep(5)
end
end)
sched.run(function()
local waitd={emitter=emitter_task, events={'ev'}}
while true do
_, m = sched.wait(waitd)
print (m)
end
end)
sched.go()
---------------------------------------------------
Good luck in your quest :)
Jorge