lua-users home
lua-l archive

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


gary ng wrote:
What I found about HTT is that it seems that I need to
write C routine in order to use it, if my "possible to

right. it's not a 'multitasking environment' for lua; it's a C toolkit to write mutually-compatible nonblocking IO modules.

block" process is not just stream IO(like my example
of say I make use of luasql and issue a SQL query
which got blocked on the server side, and in that
case, I don't even has the chance to yield from lua).

to write a module using HTT, first you design it as a usual C module. then, take any 'might block' routine, and split it into three parts: one that is called from Lua and reads all needed parameters, the second one is called from a helper thread and does most of the work, blocking if you want to, but can't access the Lua state any way. when it's done, the third part takes any result, and returns it to the Lua caller.

the Lua side of HTT lets you set threads and queues for all parameters, works and results; but if you use the included (sample) scheduler, the Lua code runs in several coroutines and yield()/resume() makes it look like usual blocking routines.

still, for most projects, i'm more and more turning to DJ. Bernstein's tools (like PA mentioned).

--
Javier