dequeue_message
— Receive one or more messages from the message queue.
dequeue_message( : : QueueHandle, GenParamName, GenParamValue : MessageHandle)
dequeue_message
dequeues a message from the message queue
denoted by the QueueHandle
parameter.
The message must have been enqueued by any thread using
enqueue_message
.
The messages are delivered in FIFO (first-in first-out) order, every message
is delivered only once. If the queue is not empty, dequeue_message
immediately delivers the oldest message from the queue. This message
is removed from the queue and a handle to the message is returned
in the MessageHandle
output parameter. The message data ownership
is transferred (no copy) from the message queue to the newly created
message handle.
If the queue is empty, dequeue_message
blocks until a message
becomes available for delivery (being queued from another thread
using enqueue_message
).
The data stored in the message can be queried using
get_message_tuple
, get_message_obj
, or
get_message_param
.
The message handles obtained through dequeue_message
can be
further reused (modified and/or enqueued to another message queue).
If multiple messages were enqueued using a single enqueue_message
call, all those messages will be also retrieved together through a single
dequeue_message
call, delivering multiple message handles via
the MessageHandle
tuple.
The queue access is internally fully synchronized, no external locking is required.
During application reconfiguration or cleanup, it might be necessary
to wake threads waiting for messages in dequeue_message
.
This can be achieved using the operator set_message_queue_param
with the parameter 'abort_dequeuing' . In such case the currently
blocked dequeue_message
calls return immediately with H_ERR_MQCNCL.
Finally, it is possible to adjust dequeue_message
behavior
through generic parameters within GenParamName
and
GenParamValue
. Currently, just a single generic parameter
is supported:
Timeout controlling how long the operator will block while waiting for a message if the queue is empty. When expired, the operator returns with H_ERR_TIMEOUT. The timeout can be specified as an integer or double value in seconds or as the string 'infinite' . When no timeout is specified, infinite timeout is used as default, meaning that the operator would block until a new message is enqueued or until the operation is aborted.
This operator returns a handle. Note that the state of an instance of this handle type may be changed by specific operators even though the handle is used as an input parameter by those operators.
QueueHandle
(input_control) message_queue →
(handle)
Message queue handle.
Number of elements: QueueHandle == 1
Restriction: QueueHandle != 0
GenParamName
(input_control) string(-array) →
(string)
Names of optional generic parameters
Number of elements: GenParamName == GenParamValue
Default value: 'timeout'
List of values: 'timeout'
GenParamValue
(input_control) tuple(-array) →
(string / integer / real)
Values of optional generic parameters
Number of elements: GenParamName == GenParamValue
Default value: 'infinite'
List of values: 'infinite'
MessageHandle
(output_control) message(-array) →
(handle)
Handle(s) of the dequeued message(s).
Number of elements: MessageHandle > 0
Assertion: MessageHandle != 0
create_message_queue (Queue) * ... dequeue_message (Queue, [], [], Message) get_message_obj (Image, Message, 'my_image')
If the operation succeeds, dequeue_message
returns 2 (H_MSG_TRUE).
Otherwise an exception is raised. Possible error conditions include
invalid parameters, message dequeue wait timeout (H_ERR_TIMEOUT)
or message dequeue wait abortion (H_ERR_MQCNCL).
Note that in some rare cases, when an error occurs when finishing the
operator call (after the message has already been removed from the queue),
the operator will attempt to requeue the message back to the front of the
queue to not loose it. This might lead to a different message delivery order
if another thread removed another message from the queue in the meanwhile.
get_message_tuple
,
get_message_obj
,
get_message_param
create_message_queue
,
clear_message_queue
,
enqueue_message
,
set_message_queue_param
,
get_message_queue_param
,
create_message
,
clear_message
,
set_message_tuple
,
get_message_tuple
,
set_message_obj
,
get_message_obj
Foundation