lua-users home
lua-l archive

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


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-+ 
|  dg@cowlark.com    | "The README of fate is a complex program indeed."
| (dg@tao-group.com) | --- Reboot
+- www.cowlark.com --+ 

Attachment: pgp17aGKQqs3U.pgp
Description: PGP signature