[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Timing out LUA programs
- From: Björn De Meyer <bjorn.demeyer@...>
- Date: Tue, 18 Jun 2002 20:27:27 +0200
Sean Middleditch wrote:
>
> Again, with Lua's co-threads support, it should be very easy (I would
> imagine - haven't look at internals in a while) to make a
> pre-emptive-ish threading system. Simply do something akin to forced
> yields, add in Lua mutex/semaphore data types, etc. The main engine
> would look at all available threads, and run each for X amount of time
> or for X byte-code operations, then return to calling C code. This way,
> an application could launch Lua threads, and then have a
> "lua_run_threads" call in the main update/event loop.
Well, that could be helpful. Such a Lua would still block when calling
the C functions, though. Contrary to what I said before, there is no
truly correct and portable way to do coroutines in plain ANSI C.
You need system-dependent extensions, and then we're even farther from
home,
so to speak.
On the other hand, it might be the question why you would use a separate
"microthread" for each and every agent in an AI system. Simply looping
over all agents in a big (timed) loop, or using some kind
of message passing and/or callbacks can be just as efficient,
not to mention a lot simpler, as you have no pains with mutexes and
semaphores.
--
"No one knows true heroes, for they speak not of their greatness." --
Daniel Remar.
Björn De Meyer
bjorn.demeyer@pandora.be