lua-users home
lua-l archive

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


On Mon, Dec 1, 2008 at 2:32 PM, Sam Roberts <vieuxtech@gmail.com> wrote:
> On Mon, Dec 1, 2008 at 11:33 AM, Patrick Donnelly
> <batrick.donnelly@gmail.com> wrote:
>>> Looks legal to me, but I can see why you wonder. I don't see why you use the
>>> thread lua_State instead of the parent lua_State.
>>
>> This is because the main lua_State thread is resuming threads and is
>> not available to execute the callback function. I thought perhaps I
>
> Now I'm confused again. We established you don't have OS threads.

I want to emphasize that whenever I say "thread", I mean Lua threads.

The main thread is resuming worker (script) threads. During the
execution of one of these worker threads a callback may be executed.
It would not be possible to handle the execution of that callback if
the main thread (which happens to be Lua code) is waiting on
coroutine.resume. That is what I meant (sorry for the confusion).

>> would need to make a simple throwaway thread for running each callback
>> function but was hoping to avoid that by just using the yielded
>> thread.
>
> I suspect there is a simpler way of doing what you are trying to do.
> Is your code available somewhere?
>
> I use nmap (my company actually has a license to it), and we use lua,
> which is why I'm a bit interested in what happens with lua in nmap. It
> might not be useful to us, but maybe it will be.

Yes it is available (if you would like more information on how it
works please e-mail me off-list).

svn co --username guest --password ""
svn://svn.insecure.org/nmap-exp/patrick/nse-lua

nse_nsock.cc (callbacks)
nse_main.cc
nse_main.lua

are particularly important.

Cheers,

-- 
-Patrick Donnelly

"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."

-Will Durant