[MacRuby-devel] Fibers and Enumerators
Scott Thompson
easco at mac.com
Tue Aug 10 20:43:08 PDT 2010
I recently had a discussion on a separate list about Coroutines and Cooperative Multitasking on Mac OS X. The general result of that discussion was that the "best" solutions were to either rely on the (deprecated) Carbon Thread Manager, use a more complex scheme involving pthreads and semaphores to emulate cooperative multitasking, or look at a third party library which uses hand-rolled assembly to replace the (deprecated, non-POSIX) makecontext, swapcontext and friends.
In the course of that discussion, I looked to see how MacRuby might be implementing Fibers (which is a coroutines mechanism similar to the one I was looking for) and found that, at the moment, it doesn't. The Fiber code is commented out (at least in the few places in the source I looked at).
Have you given some thought as to how that feature might be implemented?
I suppose with the Ruby interpreter that the "co-routine" might be handled using internal features of the interpreter itself (the "green threads", fabled in song and story). At the same time, it seems like all the work that went into improving Ruby's threading system as implemented by MacRuby might have made it harder to use the "green threads".
I'm more curious than anything else, but has someone thought of a clever way to handle cooperative multitasking in MacRuby?
Scott
More information about the MacRuby-devel
mailing list