Class OutputBarrier
java.lang.Object
org.simpleframework.http.socket.service.OutputBarrier
The
OutputBarrier is 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
FieldsModifier and TypeFieldDescriptionprivate final ChannelThis is the TCP channel the frames are delivered over.private final longThis is the length of time to wait before failing to lock.private final ReentrantLockThis is used to check if there is an operation in progress.private final ByteWriterThis is the underlying sender used to send the frames. -
Constructor Summary
ConstructorsConstructorDescriptionOutputBarrier(Request request, long duration) Constructor for theOutputBarrierobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidsend(byte[] frame) This method is used to send all frames.
-
Field Details
-
lock
This is used to check if there is an operation in progress. -
writer
This is the underlying sender used to send the frames. -
channel
This is the TCP channel the frames are delivered over. -
duration
private final long durationThis is the length of time to wait before failing to lock.
-
-
Constructor Details
-
OutputBarrier
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 Details
-
send
This 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:
IOException
-