lua-users home
lua-l archive

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



On Jan 29, 2005, at 10:34, David Burgess wrote:

PS I struggle with co-routines.

Me too :)

Here is my first perverted take on it, which pushes the LUObject madness in new uncharted territories...

In a nutshell, I'm thinking to add two new methods to the root LOObject:

(1) anObject.spawn( aMethod )
(2) anObject.yield()

(1) is the equivalent of the good, old VMS's DCL "spawn" command:

http://www.nis.com/volume_1/spawn.html

spawn() is simply a cover method to wrap 'aMethod' into a coroutine and register it with LUTask.

(2) is a cover method as well to transparently invoke coroutine.yield( this() )

Now any LUObject should be able to play nicely in the weird but wonderful world of coroutines without concerning themselves too much about what coroutines are in the first place, beside remembering to call "yield" when appropriate that is...

LUTask should take care of all the mundanities related to effectively creating coroutine and keeping track of them. In other words, LUTask not only acts as a wrapper around all the coroutine functionality but also serves as a sort of default "run loop" for them along the lines of what the "dispatcher" function does in PIL 9.4 - Non-Preemptive Multithreading.

Thoughts?


Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/