Class: Concurrent::Edge::LockFreeLinkedSet::Node
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
|
|
Instance Chain:
self,
Comparable,
Synchronization::Object ,
Synchronization::Volatile ,
Synchronization::AbstractObject
|
|
Inherits: |
Concurrent::Synchronization::Object
|
Defined in: | lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb |
Class Attribute Summary
Synchronization::Object
- Inherited
Class Method Summary
- .new(data = nil, successor = nil) ⇒ Node constructor
Synchronization::Object
- Inherited
.atomic_attribute?, .atomic_attributes, | |
.attr_atomic | Creates methods for reading and writing to a instance variable with volatile (Java) semantic as |
.attr_volatile | Creates methods for reading and writing (as |
.ensure_safe_initialization_when_final_fields_are_present | For testing purposes, quite slow. |
.new | Has to be called by children. |
.safe_initialization!, .define_initialize_atomic_fields |
Synchronization::AbstractObject
- Inherited
Instance Attribute Summary
-
#last? ⇒ Boolean
readonly
Check to see if the node is the last in the list.
Instance Method Summary
-
#<=>(other)
We use
Object#hash
as a way to enforce ordering on the nodes. - #data
- #key
-
#key_for(data)
This method provides a unqiue key for the data which will be used for ordering.
-
#next_node
Next node in the list.
- #successor_reference
Synchronization::Object
- Inherited
Synchronization::Volatile
- Included
Synchronization::AbstractObject
- Inherited
Constructor Details
.new(data = nil, successor = nil) ⇒ Node
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 11
def initialize(data = nil, successor = nil) super() @SuccessorReference = AtomicMarkableReference.new(successor || Tail.new) @Data = data @Key = key_for data end
Instance Attribute Details
#last? ⇒ Boolean
(readonly)
Check to see if the node is the last in the list.
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 31
def last? @SuccessorReference.value.is_a? Tail end
Instance Method Details
#<=>(other)
We use Object#hash
as a way to enforce ordering on the nodes. This can be configurable in the future; for example, you could enforce a split-ordering on the nodes in the set.
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 51
def <=>(other) @Key <=> other.hash end
#data
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 18
def data @Data end
#key
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 26
def key @Key end
#key_for(data)
This method provides a unqiue key for the data which will be used for ordering. This is configurable, and changes depending on how you wish the nodes to be ordered.
#next_node
Next node in the list. Note: this is not the AtomicMarkableReference
of the next node, this is the actual Node
itself.
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 37
def next_node @SuccessorReference.value end
#successor_reference
[ GitHub ]# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 22
def successor_reference @SuccessorReference end