[Python-ideas] channel (synchronous queue)
Sturla Molden
sturla at molden.no
Sun Feb 19 22:29:23 CET 2012
Den 19.02.2012 20:04, skrev Guido van Rossum:
> I think Matt Joiner's original post hinted at some. Matt, could you
> elaborate? We may be only an inch away from getting this into the
> stdlib...
One thing I could think of, is "atomic messaging" with multiple
producers or consumers talking on the same channel. E.g. while process A
sends a message to process B, process C cannot write and process D
cannot read. So you always get a 1 to 1 conversation.
But I am not sure why (or if) Go has this mechanism.
On the other hand, if we put in N**2 pipes (or channels), we could
achieve the same atomicity of transaction by having an index for sender
and receiver of a message. This is what MPI does in the functions
MPI_Send and MPI_Recv. But then I will be scolded for using to many
semaphores on FreeBSD again :-(
But there are some other useful mechanisms from MPI (and ØMQ) to
consider as well. For example message broadcasting, message scatter and
gather, and reductions. The latter is a reduce operation (e.g. add or
multiply) on messages coming in from multiple processes. OpenMP also has
reductions in the API. So there is a lot to be considered on the area of
concurrency if we want to put in more classes in threading and
multiprocessing.
But now I'll stop before someone tells me to take this to the
concurrency list :-)
Sturla
More information about the Python-ideas
mailing list