net.sf.beanlib.util.concurrent
Class ConcurrentSkipListMap.Index<K,V>

java.lang.Object
  extended by net.sf.beanlib.util.concurrent.ConcurrentSkipListMap.Index<K,V>
Direct Known Subclasses:
ConcurrentSkipListMap.HeadIndex
Enclosing class:
ConcurrentSkipListMap<K,V>

static class ConcurrentSkipListMap.Index<K,V>
extends Object

Index nodes represent the levels of the skip list. Note that even though both Nodes and Indexes have forward-pointing fields, they have different types and are handled in different ways, that can't nicely be captured by placing field in a shared abstract class.


Field Summary
(package private)  ConcurrentSkipListMap.Index<K,V> down
           
(package private)  ConcurrentSkipListMap.Node<K,V> node
           
(package private)  ConcurrentSkipListMap.Index<K,V> right
           
(package private) static AtomicReferenceFieldUpdater<ConcurrentSkipListMap.Index,ConcurrentSkipListMap.Index> rightUpdater
          Updater for casRight
 
Constructor Summary
ConcurrentSkipListMap.Index(ConcurrentSkipListMap.Node<K,V> node, ConcurrentSkipListMap.Index<K,V> down, ConcurrentSkipListMap.Index<K,V> right)
          Creates index node with given values.
 
Method Summary
(package private)  boolean casRight(ConcurrentSkipListMap.Index<K,V> cmp, ConcurrentSkipListMap.Index<K,V> val)
          compareAndSet right field
(package private)  boolean indexesDeletedNode()
          Returns true if the node this indexes has been deleted.
(package private)  boolean link(ConcurrentSkipListMap.Index<K,V> succ, ConcurrentSkipListMap.Index<K,V> newSucc)
          Tries to CAS newSucc as successor.
(package private)  boolean unlink(ConcurrentSkipListMap.Index<K,V> succ)
          Tries to CAS right field to skip over apparent successor succ.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

node

final ConcurrentSkipListMap.Node<K,V> node

down

final ConcurrentSkipListMap.Index<K,V> down

right

volatile ConcurrentSkipListMap.Index<K,V> right

rightUpdater

static final AtomicReferenceFieldUpdater<ConcurrentSkipListMap.Index,ConcurrentSkipListMap.Index> rightUpdater
Updater for casRight

Constructor Detail

ConcurrentSkipListMap.Index

ConcurrentSkipListMap.Index(ConcurrentSkipListMap.Node<K,V> node,
                            ConcurrentSkipListMap.Index<K,V> down,
                            ConcurrentSkipListMap.Index<K,V> right)
Creates index node with given values.

Method Detail

casRight

final boolean casRight(ConcurrentSkipListMap.Index<K,V> cmp,
                       ConcurrentSkipListMap.Index<K,V> val)
compareAndSet right field


indexesDeletedNode

final boolean indexesDeletedNode()
Returns true if the node this indexes has been deleted.

Returns:
true if indexed node is known to be deleted

link

final boolean link(ConcurrentSkipListMap.Index<K,V> succ,
                   ConcurrentSkipListMap.Index<K,V> newSucc)
Tries to CAS newSucc as successor. To minimize races with unlink that may lose this index node, if the node being indexed is known to be deleted, it doesn't try to link in.

Parameters:
succ - the expected current successor
newSucc - the new successor
Returns:
true if successful

unlink

final boolean unlink(ConcurrentSkipListMap.Index<K,V> succ)
Tries to CAS right field to skip over apparent successor succ. Fails (forcing a retraversal by caller) if this node is known to be deleted.

Parameters:
succ - the expected current successor
Returns:
true if successful