[ library(notify_ports) | Reference Manual | Alphabetic Index ]
open_tagged_receiver(+Tag, +SendPort, ?ReceivePort)
Create a receiver for one or more tagging senders
- Tag
- an arbitrary term
- SendPort
- a tagged-send-port structure
- ReceivePort
- a tagged-receive-port structure or a variable
Description
This predicate either creates a new receive port and connects it to an
existing tagged-send port, or connects an existing receive port to an
additional existing tagged-send port. The new receive port will receive
all messages that are sent via the send port after the receiver
has been opened. Any messages that were sent before the receiver was
opened will not be received by this receiver.
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.
Modes and Determinism
- open_tagged_receiver(+, +, -)
- open_tagged_receiver(+, +, +)
Examples
?- 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)
See Also
open_tagging_sender / 1, send_notification / 2, receive_notifications / 3, foreachnotification / 6