[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Help with Lua Threads/Coroutines/(or something)
- From: "Thomas Harning Jr." <harningt@...>
- Date: Thu, 17 Nov 2005 23:11:17 -0500
A good idea to implement this would be to use a system sort of like
actorRunner = coroutine.wrap(actorFunction)
-- arguments passed inside the actorFunction's yield call
(yieldedargs ...) = actorRunner(args,....)
for actor in actors do
returnVals = actor(arguments...)
Inside the actorFunction, you would want to have some loop that
continually does work, then calls coroutine.yield(args...)
One of the arguments that would be useful to pass into the
actor(..args..) would be an argument to tell the actor to "die",
that is, return out of the function without yielding.
With this, you wouldn't need to setup a new lua state for each
actor, as the coroutine setup would handle state preservation.
As for having the scripts schedule movement or something like that,
I'm not positive as to solutions, but the above should help.
Thomas Harning Jr.
Description: OpenPGP digital signature