Messages that arrive on ReceivePort from SendPort will get tagged with Tag, i.e. the received message will be a structure of the form
Tag : Message
If several senders are connected to ReceivePort, the tag can thus
be used to identify the origin of the message.
?- open_tagging_sender(S1),
open_tagging_sender(S2),
open_tagged_receiver(r1s1, S1, R1),
open_tagged_receiver(r1s2, S2, R1),
open_tagged_receiver(r2s1, S1, R2),
open_tagged_receiver(r2s2, S2, R2),
send_notification(S1, m1),
send_notification(S1, m2),
send_notification(S2, m3),
send_notification(S1, m4),
send_notification(S2, m5),
receive_notifications(R1, R1M1, _),
receive_notifications(R2, R2M1, _).
...
R1M1 = [r1s1 : m1, r1s1 : m2, r1s2 : m3, r1s1 : m4, r1s2 : m5]
R2M1 = [r2s1 : m1, r2s1 : m2, r2s2 : m3, r2s1 : m4, r2s2 : m5]
Yes (0.00s cpu)