Class SynchronizedMessageSourceConduit

All Implemented Interfaces:
Conduit, MessageSourceConduit, SourceConduit

public final class SynchronizedMessageSourceConduit extends AbstractSynchronizedSourceConduit<MessageSourceConduit> implements MessageSourceConduit
A synchronized message source conduit. All conduit operations are wrapped in synchronization blocks for simplified thread safety.
Author:
David M. Lloyd
  • Constructor Details

    • SynchronizedMessageSourceConduit

      public SynchronizedMessageSourceConduit(MessageSourceConduit next)
      Construct a new instance. A new lock object is created.
      Parameters:
      next - the next conduit in the chain
    • SynchronizedMessageSourceConduit

      public SynchronizedMessageSourceConduit(MessageSourceConduit next, Object lock)
      Construct a new instance.
      Parameters:
      next - the next conduit in the chain
      lock - the lock object to use
  • Method Details

    • receive

      public int receive(ByteBuffer dst) throws IOException
      Description copied from interface: MessageSourceConduit
      Receive a message.
      Specified by:
      receive in interface MessageSourceConduit
      Returns:
      the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
      Throws:
      IOException - if an I/O error occurs
    • receive

      public long receive(ByteBuffer[] dsts, int offs, int len) throws IOException
      Description copied from interface: MessageSourceConduit
      Receive a message.
      Specified by:
      receive in interface MessageSourceConduit
      offs - the offset into the array of buffers of the first buffer to read into
      len - the number of buffers to fill
      Returns:
      the size of the received message, 0 if no message is available, and -1 if the message channel has reached an end-of-file condition
      Throws:
      IOException - if an I/O error occurs