Communication de plusieurs à un et de plusieurs à plusieurs
Commencez à écouter un canal de communication plusieurs-à-un.
In[1]:=
![Click for copyable input](assets.fr/many-to-one-and-many-to-many-communication/In_1.png)
listener = ChannelListen["master"]
Out[1]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_1.png)
Envoyez des messages au canal de plusieurs sessions, par exemple, à partir de noyaux parallèles sur la même machine.
In[2]:=
![Click for copyable input](assets.fr/many-to-one-and-many-to-many-communication/In_2.png)
ParallelEvaluate[ChannelSend["master", $KernelID]]
Out[2]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_2.png)
Les messages reçus.
In[3]:=
![Click for copyable input](assets.fr/many-to-one-and-many-to-many-communication/In_3.png)
listener["Message", All]
Out[3]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_3.png)
Un schéma d'échange de messages.
Afficher l'entrée complète de Wolfram Language
Out[5]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_4.png)
Commencez à écouter sur le même canal dans plusieurs sessions parallèles du noyau.
In[6]:=
![Click for copyable input](assets.fr/many-to-one-and-many-to-many-communication/In_6.png)
ParallelEvaluate[l = ChannelListen["all"]]
Out[6]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_5.png)
Laissez tous les noyaux parallèles envoyer leurs identifiants respectifs au canal.
In[7]:=
![Click for copyable input](assets.fr/many-to-one-and-many-to-many-communication/In_7.png)
ParallelEvaluate[ChannelSend["all", $KernelID]]
Out[7]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_6.png)
Les messages reçus par les auditeurs, avec leurs numéros d'identification respectifs du noyau.
In[8]:=
![Click for copyable input](assets.fr/many-to-one-and-many-to-many-communication/In_8.png)
ParallelEvaluate[$KernelID -> l["Message", All]]
Out[8]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_7.png)
Un schéma de l'échange.
Afficher l'entrée complète de Wolfram Language
Out[9]=
![](assets.fr/many-to-one-and-many-to-many-communication/O_8.png)