Package com.yahoo.jdisc.handler
Class BlockingContentWriter
java.lang.Object
com.yahoo.jdisc.handler.BlockingContentWriter
This class provides a blocking write-interface to a
ContentChannel
. Both write(ByteBuffer)
and close()
methods provide an internal CompletionHandler
to the decorated
ContentChannel
calls, and wait for these to be called before returning. If CompletionHandler.failed(Throwable)
is called, the corresponding Throwable is thrown to the caller.- Author:
- Simon Thoresen Hult
- See Also:
-
Constructor Summary
ConstructorDescriptionBlockingContentWriter
(ContentChannel content) Creates a new BlockingContentWriter that encapsulates a givenContentChannel
. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the underlyingContentChannel
and waits for the operation to complete.void
write
(ByteBuffer buf) Writes to the underlyingContentChannel
and waits for the operation to complete.
-
Constructor Details
-
BlockingContentWriter
Creates a new BlockingContentWriter that encapsulates a givenContentChannel
.- Parameters:
content
- The ContentChannel to encapsulate.- Throws:
NullPointerException
- If the content argument is null.
-
-
Method Details
-
write
Writes to the underlyingContentChannel
and waits for the operation to complete.- Parameters:
buf
- The ByteBuffer to write.- Throws:
InterruptedException
- If the thread was interrupted while waiting.RuntimeException
- If the operation failed to complete, see cause for details.
-
close
Closes the underlyingContentChannel
and waits for the operation to complete.- Throws:
InterruptedException
- If the thread was interrupted while waiting.RuntimeException
- If the operation failed to complete, see cause for details.
-