Many-to-One and Many-to-Many Communication
Start listening on a channel for many-to-one communication.
In[1]:=
listener = ChannelListen["master"]
Out[1]=
Send messages to the channel from several sessions—for instance, from parallel kernels on the same machine.
In[2]:=
ParallelEvaluate[ChannelSend["master", $KernelID]]
Out[2]=
The received messages.
In[3]:=
listener["Message", All]
Out[3]=
A diagram of the message exchange.
show complete Wolfram Language input
Out[5]=
Start listening on the same channel in multiple parallel kernel sessions.
In[6]:=
ParallelEvaluate[l = ChannelListen["all"]]
Out[6]=
Let all the parallel kernels send their respective IDs to the channel.
In[7]:=
ParallelEvaluate[ChannelSend["all", $KernelID]]
Out[7]=
Messages received by the listeners, with their respective kernel IDs.
In[8]:=
ParallelEvaluate[$KernelID -> l["Message", All]]
Out[8]=
A diagram of the exchange.
show complete Wolfram Language input
Out[9]=