[Python-ideas] channel (synchronous queue)

Cameron Simpson cs at zip.com.au
Sun Feb 19 11:05:12 CET 2012

On 19Feb2012 01:59, Sturla Molden <sturla at molden.no> wrote:
| Den 19.02.2012 01:39, skrev Matt Joiner:
| >
| > Yes, channels can allow for this, but as with locks directionality and 
| > ordering matter. Typically messages will only run in a particular 
| > direction.
| >
| Actually, it was only a synchronous MPI_Recv that did this in MPI, a 
| synchronous
| MPI_Send would have been even worse. Which is why MPI got the
| asynchronous method MPI_Irecv...
| Sounds like you just want a barrier or a condition primitive. E.g. have 
| the sender
| call .wait() on a condition and let the receiver call .notify() the 
| condition.

A condition is essentially a boolean (with waiting).
A channel is a value passing mechanism.
Sometimes you really do want a zero-storage Queue i.e. a channel.

Saying "but you could put a value in a shared variable and just use a
condition" removes the abstraction/metaphor. If I was thinking that way
more than once in some code I'd write a small class to do that. And it would
be a channel!

Seriously, a channel is semanticly equivalent to a zero-storage Queue, which
is a mode not provided by the current Queue implementation.
Cameron Simpson <cs at zip.com.au> DoD#743

No good deed shall go unpunished!       - David Wood <davewood at teleport.com>

More information about the Python-ideas mailing list