[Stackless] Event-based scheduling

Tim Kientzle tim at metaweb.com
Wed Feb 13 23:26:25 CET 2008


On Feb 13, 2008, at 1:05 PM, Laurent Debacker wrote:
> I don't understand why the implementation forces me to use channels,  
> if I do not need to 'transfer' data. You use the channel as a  
> semaphore. I would think that it is better to implement semaphore,  
> and then implement channels based on semaphores.

I think you're getting confused by the name.  After
using it a bit, I now think of a stackless "channel"
as a synchronization primitive that happens to offer
some basic data transfer support.

If you examine the implementation, you'll see that
the data transfer support is very nearly free, so a
two-layer implementation as you suggest would really
be a waste of effort.

If you don't need data transfer, just ignore that
part of the channel interface (pass None, ignore the
return value).  Treating a channel as a semaphore is
a completely reasonable thing to do, since that's
essentially what it is.

Tim Kientzle





More information about the Stackless mailing list