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 Channel
This is the TCP channel the frames are delivered over.private final long
This is the length of time to wait before failing to lock.private final ReentrantLock
This is used to check if there is an operation in progress.private final ByteWriter
This is the underlying sender used to send the frames. -
Constructor Summary
ConstructorsConstructorDescriptionOutputBarrier
(Request request, long duration) Constructor for theOutputBarrier
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
send
(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 theOutputBarrier
object. This is used to ensure that if there is currently a blocking write in place that theSessionChecker
will 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
-