Boost logo

Boost :

From: Daniel James (daniel_at_[hidden])
Date: 2005-06-03 03:33:39


Jonathan Turkanis wrote:

> I remember Daniel James had written a coroutine library. Here's the message:
> http://lists.boost.org/boost/2005/01/18687.php. The code is available here, but
> doesn't appear to be well documented:
> ttp://myweb.tiscali.co.uk/calamity/code/coroutines.tar.gz.

It's also a mess and very, very ugly :(. But it does work. I was really
just experimenting with how far I could push the idea. I was thinking of
trying to simplify it a bit but never got round to it as I didn't have
any need for this myself. One thing I was considering was making use of
phoenix's closures, although that might have ended up being quite verbose.

But it wouldn't be to hard to add recursion to something like Maksym's
version which would make it a lot more powerful. And I'm not sure why he
needs 'YIELD_FOR' and 'YIELD_IF'. I think it could quite easily be
written so that his example would be:

class simple_generator
{
public:
     YIELD_BEGIN_WITH_CTOR( simple_generator, int )
         for( i = 1, i < 4, ++i ) {
             for( j = 1, j < 4, ++j ) {
                 YIELD_RETURN( i * j )
             }
         }
     YIELD_END
private:
     int i;
     int j;
};


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk