MessageScheduler¶
Scheduler for external input messages
-
class
messageScheduler.
MessageScheduler
[source]¶ An efficient implementation of a message scheduler for the inputQueue, it supports very fast invalidations (O(1)) and fast retrievals of first element (O(log(n) in average case)
-
cleanFirst
()[source]¶ Clean all invalid messages at the front of the list. Method MUST be called before any accesses should happen to the first element, otherwise this first element might be a message that was just invalidated
-
cleanup
(time)[source]¶ Clean up the processed list, also removes all invalid elements
Parameters: time – time up to which cleanups are allowed to happen
-
extract
(model_ids)[source]¶ Extract messages from the message scheduler for when a model gets removed from this kernel.
Parameters: model_ids – iterable of model_ids of models that will be removed from this node Returns: tuple – extraction that needs to be passed to the insert method of another scheduler
-
insert
(extraction, model_list)[source]¶ Insert several messages that were created elsewhere and merge them in.
Parameters: - extraction – the output of the extract method on the other message scheduler
- model_list – models that are inserted and for which extraction happened
-
massUnschedule
(uuids)[source]¶ Unschedule several messages, this way it will no longer be processed.
Parameters: uuids – iterable of UUIDs that need to be removed
-
purgeFirst
()[source]¶ Notify that the first (valid) message must be removed
Returns: msg – the next first message that is valid
-
readFirst
()[source]¶ Returns the first (valid) message. Not necessarily O(1), as it could be the case that a lot of invalid messages are still to be deleted.
-
removeFirst
()[source]¶ Notify that the first (valid) message is processed.
Returns: msg – the next first message that is valid
-