From: Pit Capitain Date: 2001-11-04T05:42:17+09:00 Subject: [ruby-talk:24288] Re: cost of threads vs. continuations Hi Avi, when I developed my Iterator class (see ruby-talk:20270) which uses continuations, I (of course : ) had a number of unit tests. Running the test suite several times gave me out of memory errors, IIRC. When I changed the implementation to release all references to the continuation objects as soon as they weren't needed anymore the out of memory errors went away. Might be a hint that continuations aren't cheap... On 2 Nov 2001, at 9:41, Avi Bryant wrote: > How different are the costs of a continuation and a suspended thread? > It seems like they ought to be almost identical, but is there anything > in the internals that makes one preferable to the other? Is it > reasonable to have, say, a hundred or even a few hundred active > threads or continuations at once? > > I'm playing with extending iowa to allow web apps written in something > like a continuation-passing style (normally, passing control to > another page is much like a goto, One of the first implementations of the Iterator class used a module named Goto : ) that was intended to make the use of continuations easier to read. > , and I want to allow something that > looks like a subroutine call), and although the idea is most naturally > expressed using call/cc it may be hackable with threads instead. Of > course, if continuations are cheaper, then I won't bother. ;-) > > Avi Regards, Pit