MessageProcessor - laforge49/Asynchronous-Functional-Programming GitHub Wiki

Objects which receive messages must implement the MessageProcessor trait.

Note that the API does not pass messages directly to a MessageProcessor object, but instead a MessageProcessor object is informed when there is a message to be processed and called to process a message. Doing things this way facilitates the implementation of the code used to achieve high-performance.

/**
 * A MessageProcessor object processes messages and
 * receives notifications that there are messages to be processed.
 */
trait MessageProcessor[T] {
  /**
   * The processMessage method is called when
   * there may be an incoming message to process.
   */
  def processMessage(message: T)

  /**
   * The haveMessage method is called when
   * there may be an incoming message to be processed.
   */
  def haveMessage
}

MessageProcessor

Asyncronous Messaging