Class OutputBarrier

java.lang.Object
org.simpleframework.http.socket.service.OutputBarrier

class OutputBarrier extends Object
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

    Fields
    Modifier and Type
    Field
    Description
    private 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

    Constructors
    Constructor
    Description
    OutputBarrier(Request request, long duration)
    Constructor for the OutputBarrier object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    send(byte[] frame)
    This method is used to send all frames.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • lock

      private final 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 Details

    • OutputBarrier

      public OutputBarrier(Request request, long duration)
      Constructor for the OutputBarrier object. This is used to ensure that if there is currently a blocking write in place that the SessionChecker 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 from
      duration - this is the length of time to wait for the lock
  • Method Details

    • send

      public void send(byte[] frame) throws IOException
      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