Package org.xnio.conduits

# Class SynchronizedMessageSinkConduit

java.lang.Object
org.xnio.conduits.AbstractConduit<MessageSinkConduit>
org.xnio.conduits.AbstractSynchronizedConduit<MessageSinkConduit>
org.xnio.conduits.AbstractSynchronizedSinkConduit<MessageSinkConduit>
org.xnio.conduits.SynchronizedMessageSinkConduit

All Implemented Interfaces:
  `Conduit`, `MessageSinkConduit`, `SinkConduit`

public final class SynchronizedMessageSinkConduit extends AbstractSynchronizedSinkConduit<MessageSinkConduit> implements MessageSinkConduit
A synchronized message sink conduit. All conduit operations are wrapped in synchronization blocks for simplified thread safety.

Author:
  David M. Lloyd

## Field Summary

### Fields inherited from class org.xnio.conduits.AbstractSynchronizedConduit

`lock`

### Fields inherited from class org.xnio.conduits.AbstractConduit

`next`

## Constructor Summary

Constructors
Constructor
Description
`SynchronizedMessageSinkConduit(MessageSinkConduit next)`
Construct a new instance.
`SynchronizedMessageSinkConduit(MessageSinkConduit next, Object lock)`
Construct a new instance.

## Method Summary

Modifier and Type
Method
Description
`boolean`
`send(ByteBuffer src)`
Send a complete message.
`boolean`
`send(ByteBuffer[] srcs, int offs, int len)`
Send a complete message.
`boolean`
`sendFinal(ByteBuffer src)`
Send a complete message.
`boolean`
`sendFinal(ByteBuffer[] srcs, int offs, int len)`
Send a complete message.

### Methods inherited from class org.xnio.conduits.AbstractSynchronizedSinkConduit

`awaitWritable, awaitWritable, flush, getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, terminateWrites, truncateWrites, wakeupWrites`

### Methods inherited from class org.xnio.conduits.AbstractConduit

`getWorker`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.xnio.conduits.Conduit

`getWorker`

### Methods inherited from interface org.xnio.conduits.SinkConduit

`awaitWritable, awaitWritable, flush, getWriteThread, isWriteResumed, isWriteShutdown, resumeWrites, setWriteReadyHandler, suspendWrites, terminateWrites, truncateWrites, wakeupWrites`

## Constructor Details

### SynchronizedMessageSinkConduit

public SynchronizedMessageSinkConduit(MessageSinkConduit next)
Construct a new instance. A new lock object is created.

Parameters:
  `next` - the next conduit in the chain

### SynchronizedMessageSinkConduit

public SynchronizedMessageSinkConduit(MessageSinkConduit next, Object lock)
Construct a new instance.

Parameters:
  `next` - the next conduit in the chain
  `lock` - the lock object to use

## Method Details

### send

public boolean send(ByteBuffer src) throws IOException
Description copied from interface: `MessageSinkConduit`
Send a complete message.

Specified by:
  `send` in interface `MessageSinkConduit`
Parameters:
  `src` - the message to send
Returns:
  the result of the send operation; `true` if the message was sent, or `false` if it would block
Throws:
  `IOException` - if an I/O error occurs

### send

public boolean send(ByteBuffer[] srcs, int offs, int len) throws IOException
Description copied from interface: `MessageSinkConduit`
Send a complete message.

Specified by:
  `send` in interface `MessageSinkConduit`
Parameters:
  `srcs` - the buffers holding the message to send
  `offs` - the offset into the buffer array of the first buffer
  `len` - the number of buffers that contain data to send
Returns:
  the result of the send operation; `true` if the message was sent, or `false` if it would block
Throws:
  `IOException` - if an I/O error occurs

### sendFinal

public boolean sendFinal(ByteBuffer src) throws IOException
Description copied from interface: `MessageSinkConduit`
Send a complete message. If the message is successfully sent then the sink will have its writes terminated.

Specified by:
  `sendFinal` in interface `MessageSinkConduit`
Parameters:
  `src` - the message to send
Returns:
  the result of the send operation; `true` if the message was sent, or `false` if it would block
Throws:
  `IOException` - if an I/O error occurs

### sendFinal

public boolean sendFinal(ByteBuffer[] srcs, int offs, int len) throws IOException
Description copied from interface: `MessageSinkConduit`
Send a complete message. If the message is successfully sent then the sink will have its writes terminated.

Specified by:
  `sendFinal` in interface `MessageSinkConduit`
Parameters:
  `srcs` - the buffers holding the message to send
  `offs` - the offset into the buffer array of the first buffer
  `len` - the number of buffers that contain data to send
Returns:
  the result of the send operation; `true` if the message was sent, or `false` if it would block
Throws:
  `IOException` - if an I/O error occurs