Class MessagePasser<K,​V>

java.lang.Object
org.apfloat.internal.MessagePasser<K,​V>
Type Parameters:
K - The receiver type for this message passer.
V - The message type for this message passer.

public class MessagePasser<K,​V> extends Object
Message passing helper class for parallel codes. The message passer can hold one message for each receiver. This class is safe for concurrent use from multiple threads.
Since:
1.6
Version:
1.9.0
Author:
Mikko Tommila
  • Constructor Details

    • MessagePasser

      public MessagePasser()
      Default constructor.
  • Method Details

    • sendMessage

      public void sendMessage(K receiver, V message)
      Send a message.
      Parameters:
      receiver - The receiver.
      message - The message. Must not be null.
    • getMessage

      public V getMessage(K receiver)
      Get a message if one is available. This method will not block.
      Parameters:
      receiver - The receiver.
      Returns:
      The message, or null if none is available.
    • receiveMessage

      public V receiveMessage(K receiver) throws ApfloatRuntimeException
      Receive a message. This method will block until a message is available.
      Parameters:
      receiver - The receiver.
      Returns:
      The message.
      Throws:
      ApfloatRuntimeException