[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: LibEvent binding to Lua? Mix w/ HelperThreads?
- From: Adrian Sietsma <adrian_groups@...>
- Date: Tue, 04 Apr 2006 14:04:40 +1000
From a Lua pov., what I would like to be able to do in an async io world is
either this:
s,err = wait_read(object,size,timeout) -- yields to the scheduler until data
available or timeout
...
wait_event(object,timeout) -- yields to the scheduler until event or timeout
or (contract approach)
token=read(object,size)
...
...
s, err = get_data(token)-- return any data so far
...
...
wait_for_completion(token,timeout) -- yields
s,err = get_data(token)
The first approach can be implemented using either select or overlapped io
(I have implemented it using LuaSocket); from the Lua side, the thread just
"sleeps" until data is there.
My current project uses an event iterator that returns triggered events
(socket/timer/user) when called (again using LuaSocket); and a coroutine
dispatcher that associates event with coroutines, and resumes the
appropriate coro for the event. This approach could easily be integrated
with overlapped io.
Anyway, as I see it there are 3 basic actions:
1/ Initiate a request
2/ Check (poll) the status/results of a request.
3/ Wait for a request to be fulfilled.
3 requires some sort of sheduler, although that can be based on
3a/ Wait for the next outstanding request to be fulfilled.
Any higher-level interface can be built from these primitives.
I see no alternative to different implementations for *nix and windows, but
it would be nice to have an abstraction/interface built around the Lua usage
requirements, not the os primitives.
Adrian