[ ECLiPSe message passing built-in.|Group Index|
Full Index]
mps_port_allocate(+NotifyPred, -Port)
Allocate a new message passing Port with notification predicate NotifyPred.
- +NotifyPred
- Term of the form atom/integer.
- -Port
- A variable.
Description
Ports are the end-points of communication, ie. the points where
messages are sent. A process that wants to receive communication
needs to allocate a port and tell the port identifier to the potential
senders. The senders, which will normally be other processes,
possibly on remote machines, can then send messages to the port.
The owner of the port, ie. the process that allocated it, can then
receive the messages using mps_receive/2.
Ports are allocated and deallocated with the mps_port_allocate/2 and
mps_port_deallocate/1 predicates. A port may be associated with a
notification predicate.
Ports queue incoming messages. A port's notification predicate is
called by the message passing system whenever a message is delivered
to the port with an empty queue. Note that further messages arriving
on the non-empty port do not trigger the notification predicate again.
The notifier therefore has to take into account that there may be
several messages ready to receive.
Notification predicates have one optional parameter via which the
message passing system passes the identifier of the empty port on
which a message arrived. If no notification is wanted (ie. for
polling) set NotifyPred to true/0.
Fail Conditions
None.
Resatisfiable
No.
Exceptions
- (4) Instantiation fault
- NotifyPred is not instatiated
- (5) Type error
- NotifyPred is not of the form atom/integer
- (6) Range error
- NotifyPred has wrong arity
- (60)
- The specified notification predicate does not exist
- (176)
- Message passing system error
Examples
[eclipse 1]: mps_init(breeze).
yes.
[eclipse 2]: mps_port_allocate(true/0, Port).
Port = 2050162692
yes.
[eclipse 3]: mps_send(2050162692,"Hello World !").
yes.
[eclipse 4]: mps_receive(2050162692, Message).
Message = "Hello World !"
yes.
[eclipse 5]: mps_port_deallocate(2050162692).
yes.
[eclipse 6]: mps_exit.
yes.
See Also
mps_init / 1, mps_ping / 1, mps_exit / 0, mps_port_register / 4, mps_port_lookup / 3, mps_port_deregister / 3, mps_port_deallocate / 1, mps_send / 2, mps_receive / 2