Class OutputBarrier
- java.lang.Object
-
- org.simpleframework.http.socket.service.OutputBarrier
-
class OutputBarrier extends java.lang.ObjectTheOutputBarrieris used to ensure that control frames and data frames do not get sent at the same time. Sending both at the same time could lead to the status checking thread being blocked and this could eventually exhaust the thread pool.
-
-
Field Summary
Fields Modifier and Type Field Description private ChannelchannelThis is the TCP channel the frames are delivered over.private longdurationThis is the length of time to wait before failing to lock.private java.util.concurrent.locks.ReentrantLocklockThis is used to check if there is an operation in progress.private ByteWriterwriterThis is the underlying sender used to send the frames.
-
Constructor Summary
Constructors Constructor Description OutputBarrier(Request request, long duration)Constructor for theOutputBarrierobject.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidsend(byte[] frame)This method is used to send all frames.
-
-
-
Field Detail
-
lock
private final java.util.concurrent.locks.ReentrantLock lock
This is used to check if there is an operation in progress.
-
writer
private final ByteWriter writer
This is the underlying sender used to send the frames.
-
channel
private final Channel channel
This is the TCP channel the frames are delivered over.
-
duration
private final long duration
This is the length of time to wait before failing to lock.
-
-
Constructor Detail
-
OutputBarrier
public OutputBarrier(Request request, long duration)
Constructor for theOutputBarrierobject. This is used to ensure that if there is currently a blocking write in place that theSessionCheckerwill not end up being blocked if it attempts to send a control frame.- Parameters:
request- this is the request to get the TCP channel fromduration- this is the length of time to wait for the lock
-
-
Method Detail
-
send
public void send(byte[] frame) throws java.io.IOExceptionThis method is used to send all frames. It is important that a lock is used to protect this so that if there is an attempt to send out a control frame while the connection is blocked there is an exception thrown.- Parameters:
frame- this is the frame to send over the TCP channel- Throws:
java.io.IOException
-
-