Interface Kernel

All Known Implementing Classes:
AbstractKernel, SelectorKernel, UdpKernel

public interface Kernel
Defines the basic byte[] passing messaging kernel.
Author:
Paul Speed
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Envelope
    A marker envelope returned from read() that indicates that there are events pending.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    broadcast(Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy)
    Dispatches the data to all endpoints managed by the kernel that match the specified endpoint filter.
    boolean
    Returns true if there are waiting envelopes.
    void
    Initializes the kernel and starts any internal processing.
    Removes and returns one endpoint event from the event queue or null if there are no endpoint events.
    Removes one envelope from the received messages queue or blocks until one is available.
    void
    Gracefully terminates the kernel and stops any internal daemon processing.
  • Field Details

    • EVENTS_PENDING

      static final Envelope EVENTS_PENDING
      A marker envelope returned from read() that indicates that there are events pending. This allows a single thread to more easily process the envelopes and endpoint events.
  • Method Details

    • initialize

      void initialize()
      Initializes the kernel and starts any internal processing.
    • terminate

      void terminate() throws InterruptedException
      Gracefully terminates the kernel and stops any internal daemon processing. This method will not return until all internal threads have been shut down.
      Throws:
      InterruptedException - if the calling thread is interrupted while waiting
    • broadcast

      void broadcast(Filter<? super Endpoint> filter, ByteBuffer data, boolean reliable, boolean copy)
      Dispatches the data to all endpoints managed by the kernel that match the specified endpoint filter. If 'copy' is true then the implementation will copy the byte buffer before delivering it to endpoints. This allows the caller to reuse the data buffer. Though it is important that the buffer not be changed by another thread while this call is running. Only the bytes from data.position() to data.remaining() are sent.
      Parameters:
      filter - the endpoint filter used to select recipients
      data - the payload to send
      reliable - true to use reliable transport semantics
      copy - true to copy the buffer before dispatching it
    • hasEnvelopes

      boolean hasEnvelopes()
      Returns true if there are waiting envelopes.
      Returns:
      true if at least one envelope is queued
    • read

      Removes one envelope from the received messages queue or blocks until one is available.
      Returns:
      the next queued envelope
      Throws:
      InterruptedException - if interrupted while waiting for an envelope
    • nextEvent

      EndpointEvent nextEvent()
      Removes and returns one endpoint event from the event queue or null if there are no endpoint events.
      Returns:
      the next endpoint event, or null if none are queued