[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Coroutines & scheduler query
- From: David Given <dg@...>
- Date: Fri, 10 Feb 2006 12:19:55 +0000
I have a project for which I'm going to want a large number of coroutines, all
communicating via a scheduler. Unfortunately, while I'm pretty much up to
speed with the rest of Lua, this isn't an area I've had much experience with.
I remember reading on the list that using a scheduler in this way is not
compatible with using coroutines to invert control flow, for example when
using a producer/consumer system. This seems to be because the scheduler
would have to resume a particular thread with coroutine.resume(), which means
that when that thread yields, expecting to go back to its caller, it'll
instead end up at the scheduler.
Are there any nifty ways round this?
In addition, is there any fundamental difference between coroutine.resume()
and coroutine.yield(), apart from the fact that yield knows which coroutine
to switch to automatically? Can I use resume() to keep switching between two
different coroutines without eating huge quantities of stack space?
+- David Given --McQ-+
| email@example.com | "The README of fate is a complex program indeed."
| (firstname.lastname@example.org) | --- Reboot
+- www.cowlark.com --+
Description: PGP signature