Class LinkedTransferQueue.Node

java.lang.Object
org.glassfish.jersey.internal.util.collection.LinkedTransferQueue.Node
Enclosing class:
LinkedTransferQueue<E>

static final class LinkedTransferQueue.Node extends Object
Queue nodes. Uses Object, not E, for items to allow forgetting them after use. Relies heavily on Unsafe mechanics to minimize unnecessary ordering constraints: Writes that are intrinsically ordered wrt other accesses or CASes use simple relaxed forms.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    (package private) final boolean
     
    (package private) Object
     
    private static final long
     
    (package private) LinkedTransferQueue.Node
     
    private static final long
     
    private static final long
     
    private static final sun.misc.Unsafe
     
    (package private) Thread
     
    private static final long
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Node(Object item, boolean isData)
    Constructs a new node.
  • Method Summary

    Modifier and Type
    Method
    Description
    (package private) final boolean
    cannotPrecede(boolean haveData)
    Returns true if a node with the given mode cannot be appended to this node because this node is unmatched and has opposite data mode.
    (package private) final boolean
    casItem(Object cmp, Object val)
     
    (package private) final boolean
     
    (package private) final void
    Sets item to self and waiter to null, to avoid garbage retention after matching or cancelling.
    (package private) final void
    Links node to itself to avoid garbage retention.
    (package private) final boolean
    Returns true if this node has been matched, including the case of artificial matches due to cancellation.
    (package private) final boolean
    Returns true if this is an unmatched request node.
    (package private) final boolean
    Tries to artificially match a data node -- used by remove.

    Methods inherited from class java.lang.Object

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

    • isData

      final boolean isData
    • item

      volatile Object item
    • next

      volatile LinkedTransferQueue.Node next
    • waiter

      volatile Thread waiter
    • serialVersionUID

      private static final long serialVersionUID
      See Also:
    • UNSAFE

      private static final sun.misc.Unsafe UNSAFE
    • itemOffset

      private static final long itemOffset
    • nextOffset

      private static final long nextOffset
    • waiterOffset

      private static final long waiterOffset
  • Constructor Details

    • Node

      Node(Object item, boolean isData)
      Constructs a new node. Uses relaxed write because item can only be seen after publication via casNext.
  • Method Details

    • casNext

      final boolean casNext(LinkedTransferQueue.Node cmp, LinkedTransferQueue.Node val)
    • casItem

      final boolean casItem(Object cmp, Object val)
    • forgetNext

      final void forgetNext()
      Links node to itself to avoid garbage retention. Called only after CASing head field, so uses relaxed write.
    • forgetContents

      final void forgetContents()
      Sets item to self and waiter to null, to avoid garbage retention after matching or cancelling. Uses relaxed writes because order is already constrained in the only calling contexts: item is forgotten only after volatile/atomic mechanics that extract items. Similarly, clearing waiter follows either CAS or return from park (if ever parked; else we don't care).
    • isMatched

      final boolean isMatched()
      Returns true if this node has been matched, including the case of artificial matches due to cancellation.
    • isUnmatchedRequest

      final boolean isUnmatchedRequest()
      Returns true if this is an unmatched request node.
    • cannotPrecede

      final boolean cannotPrecede(boolean haveData)
      Returns true if a node with the given mode cannot be appended to this node because this node is unmatched and has opposite data mode.
    • tryMatchData

      final boolean tryMatchData()
      Tries to artificially match a data node -- used by remove.