MessageQueue¶
Just like ordinary queues
message queues work according to First-In first-out principle.
You can read more about queues on Wikipedia.
Whenever you send a message to a CPU or a vessel it gets added to the end of that CPU’s or vessel’s message queue. The recipient can then read those messages from the queue.
Accessing message queues¶
You can access the current processor’s message queue using CORE:MESSAGES
:
SET QUEUE TO CORE:MESSAGES.
PRINT "Number of messages on the queue: " + QUEUE:LENGTH.
The current vessel’s message queue can be accessed using Vessel:MESSAGES
:
SET QUEUE TO SHIP:MESSAGES.
Structure¶
-
structure
MessageQueue
¶ Suffix Type Description EMPTY
Boolean
true if there are messages in the queue LENGTH
Scalar
number of messages in the queue POP()
Message
returns the oldest element in the queue and removes it PEEK()
Message
returns the oldest element in the queue without removing it CLEAR()
None remove all messages PUSH(message)
None explicitly append a message
-
MessageQueue:
POP
()¶ Returns the first (oldest) message in the queue and removes it. Messages in the queue are always ordered by their arrival date.
-
MessageQueue:
PEEK
()¶ Returns: Message
Returns the oldest message in the queue without removing it from the queue.
-
MessageQueue:
CLEAR
()¶ Removes all messages from the queue.
-
MessageQueue:
PUSH
(message)¶ Parameters: - message –
Message
message to be added
You can use this message to explicitly add a message to this queue. This will insert this exact message to the queue, all attributes that are normally added automatically by kOS (
Message:SENTAT
,Message:RECEIVEDAT
andMessage:SENDER
) will not be changed.- message –