lua-users home
lua-l archive

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


I've be using coroutine and write a dispatcher to a server program
written by lua. The basic idea (psudo code) is like this:

    for i=#threads,1,-1 do resume thread[i] and check the result
    if all threads are yield by socket timeout, then do
for all socket
until #threads == 0

the thread itself will handle the global table, which stores all
pending socket for

Now I want to add timer feature, so that threads can suspend for a
specific time and then resume.

The problem is that timer threads are not yielded by a socket timeout,
so does not work for timer. When I do and
any timer expires, select() still blocks.

Is it possible that the select() works both for socket and timer? or
is there any good practise to dispatch both threads yield by socket
timeout and those who yield by timer like sleep()?