Class Writer.Reentrant

java.lang.Object
org.glassfish.grizzly.Writer.Reentrant
Enclosing interface:
Writer<L>

public static final class Writer.Reentrant extends Object
Write reentrants counter
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    dec()
    Decrements the reentrants counter by one.
    int
    get()
    Returns the value of the reentrants counter for the current thread.
    static int
    Returns the maximum number of write() method reentrants a thread is allowed to made.
    Returns the current write reentrants counter.
    boolean
    inc()
    Increments the reentrants counter by one.
    boolean
    Returns true, if max number of write->completion-handler reentrants has been reached for the passed Writer.Reentrant object, and next write will happen in the separate thread.

    Methods inherited from class java.lang.Object

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

    • Reentrant

      public Reentrant()
  • Method Details

    • getMaxReentrants

      public static int getMaxReentrants()
      Returns the maximum number of write() method reentrants a thread is allowed to made. This is related to possible write()->onComplete()->write()->... chain, which may grow infinitely and cause StackOverflow. Using maxWriteReentrants value it's possible to limit such a chain.
      Returns:
      the maximum number of write() method reentrants a thread is allowed to make.
    • getWriteReentrant

      public static Writer.Reentrant getWriteReentrant()
      Returns the current write reentrants counter. Might be useful, if developer wants to use custom notification mechanism, based on on Writer.canWrite(org.glassfish.grizzly.Connection) and various write methods.
      Returns:
      current reentrants counter
    • get

      public int get()
      Returns the value of the reentrants counter for the current thread.
    • inc

      public boolean inc()
      Increments the reentrants counter by one.
      Returns:
      true if the counter (after incrementing) didn't reach getMaxReentrants() limit, or false otherwise.
    • dec

      public boolean dec()
      Decrements the reentrants counter by one.
      Returns:
      true if the counter (after decrementing) didn't reach getMaxReentrants() limit, or false otherwise.
    • isMaxReentrantsReached

      public boolean isMaxReentrantsReached()
      Returns true, if max number of write->completion-handler reentrants has been reached for the passed Writer.Reentrant object, and next write will happen in the separate thread.
      Returns:
      true, if max number of write->completion-handler reentrants has been reached for the passed Writer.Reentrant object, and next write will happen in the separate thread.