Package com.yahoo.jdisc.handler
Class BlockingContentWriter
- java.lang.Object
-
- com.yahoo.jdisc.handler.BlockingContentWriter
-
public final class BlockingContentWriter extends java.lang.Object
This class provides a blocking write-interface to aContentChannel
. Bothwrite(ByteBuffer)
andclose()
methods provide an internalCompletionHandler
to the decoratedContentChannel
calls, and wait for these to be called before returning. IfCompletionHandler.failed(Throwable)
is called, the corresponding Throwable is thrown to the caller.- Author:
- Simon Thoresen Hult
- See Also:
FastContentWriter
-
-
Constructor Summary
Constructors Constructor Description BlockingContentWriter(ContentChannel content)
Creates a new BlockingContentWriter that encapsulates a givenContentChannel
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes the underlyingContentChannel
and waits for the operation to complete.void
write(java.nio.ByteBuffer buf)
Writes to the underlyingContentChannel
and waits for the operation to complete.
-
-
-
Constructor Detail
-
BlockingContentWriter
public BlockingContentWriter(ContentChannel content)
Creates a new BlockingContentWriter that encapsulates a givenContentChannel
.- Parameters:
content
- The ContentChannel to encapsulate.- Throws:
java.lang.NullPointerException
- If the content argument is null.
-
-
Method Detail
-
write
public void write(java.nio.ByteBuffer buf) throws java.lang.InterruptedException
Writes to the underlyingContentChannel
and waits for the operation to complete.- Parameters:
buf
- The ByteBuffer to write.- Throws:
java.lang.InterruptedException
- If the thread was interrupted while waiting.java.lang.RuntimeException
- If the operation failed to complete, see cause for details.
-
close
public void close() throws java.lang.InterruptedException
Closes the underlyingContentChannel
and waits for the operation to complete.- Throws:
java.lang.InterruptedException
- If the thread was interrupted while waiting.java.lang.RuntimeException
- If the operation failed to complete, see cause for details.
-
-