# MessageScheduler

Scheduler for external input messages

class pypdevs.messageScheduler.MessageScheduler

  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)

  __init__()

    Constructor.

  cleanFirst()

    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)

    Clean up the processed list, also removes all invalid elements

    Parameters

      time – time up to which cleanups are allowed to happen

  extract(model_ids)

    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)

    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)

    Unschedule several messages, this way it will no longer be processed.

    Parameters

      uuids – iterable of UUIDs that need to be removed

  purgeFirst()

    Notify that the first (valid) message must be removed

    Returns

      msg – the next first message that is valid

  readFirst()

    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()

    Notify that the first (valid) message is processed.

    Returns

      msg – the next first message that is valid

  revert(time)

    Revert the inputqueue to the specified time, will also clean up the list of processed elements

    Parameters

      time – time to which revertion should happen

  schedule(msg)

    Schedule a message for processing

    Parameters

      msg – the message to schedule