- Type Parameters:
L- the writer address type
- All Known Subinterfaces:
AsyncQueueWriter<L>
- All Known Implementing Classes:
AbstractNIOAsyncQueueWriter,AbstractWriter,TCPNIOAsyncQueueWriter,TCPNIOTemporarySelectorWriter,TemporarySelectorWriter,UDPNIOAsyncQueueWriter,UDPNIOTemporarySelectorWriter
public interface Writer<L>
Implementations of this interface are able to write data from a
Buffer to Connection.
There are two basic Writer implementations in Grizzly: AsyncQueueWriter,
TemporarySelectorWriter.- Author:
- Alexey Stashok
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classWrite reentrants counter -
Method Summary
Modifier and TypeMethodDescriptionbooleancanWrite(Connection<L> connection) Returntrueif the connection has not exceeded it's maximum size in bytes of pending writes, otherwisefalse.voidnotifyWritePossible(Connection<L> connection, WriteHandler writeHandler) RegistersWriteHandler, which will be notified ones at least one byte can be written.write(Connection<L> connection, L dstAddress, WritableMessage message) Method writes theWritableMessageto the specific address.voidwrite(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler) Method writes theWritableMessageto the specific address.voidwrite(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler, MessageCloner<WritableMessage> messageCloner) Method writes theWritableMessageto the specific address.voidwrite(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler, PushBackHandler pushBackHandler) Deprecated.push back logic is deprecatedwrite(Connection<L> connection, WritableMessage message) Method writes theWritableMessage.voidwrite(Connection<L> connection, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler) Method writes theWritableMessage.
-
Method Details
-
write
GrizzlyFuture<WriteResult<WritableMessage,L>> write(Connection<L> connection, WritableMessage message) throws IOException Method writes theWritableMessage.- Parameters:
connection- theConnectionto write tomessage- theWritableMessage, from which the data will be written- Returns:
Future, using which it's possible to check the result- Throws:
IOException- not thrown
-
write
void write(Connection<L> connection, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler) Method writes theWritableMessage.- Parameters:
connection- theConnectionto write tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completed
-
write
GrizzlyFuture<WriteResult<WritableMessage,L>> write(Connection<L> connection, L dstAddress, WritableMessage message) Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address theWritableMessagewill be sent tomessage- theWritableMessage, from which the data will be written- Returns:
Future, using which it's possible to check the result
-
write
void write(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler) Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address theWritableMessagewill be sent tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completed
-
write
@Deprecated void write(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler, PushBackHandler pushBackHandler) Deprecated.push back logic is deprecatedMethod writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address theWritableMessagewill be sent tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completedpushBackHandler-PushBackHandler, which will be notified if message was accepted by transport write queue or refused
-
write
void write(Connection<L> connection, L dstAddress, WritableMessage message, CompletionHandler<WriteResult<WritableMessage, L>> completionHandler, MessageCloner<WritableMessage> messageCloner) Method writes theWritableMessageto the specific address.- Parameters:
connection- theConnectionto write todstAddress- the destination address theWritableMessagewill be sent tomessage- theWritableMessage, from which the data will be writtencompletionHandler-CompletionHandler, which will get notified, when write will be completedmessageCloner- theMessageCloner, which will be able to clone the message in case it can't be completely written in the current thread.
-
canWrite
Returntrueif the connection has not exceeded it's maximum size in bytes of pending writes, otherwisefalse.- Parameters:
connection- theConnectionto test whether or not the specified number of bytes can be written to.- Returns:
trueif the connection has not exceeded it's maximum size in bytes of pending writes, otherwisefalse- Since:
- 2.3
-
notifyWritePossible
RegistersWriteHandler, which will be notified ones at least one byte can be written. This method call is equivalent to call notifyWritePossible(connection, writeHandler, 1); Note: using this method from different threads simultaneously may lead to quick situation changes, so at timeWriteHandleris called - the queue may become busy again.- Parameters:
connection-ConnectionwriteHandler-WriteHandlerto be notified.- Since:
- 2.3
-