Class: Concurrent::Edge::LockFreeLinkedSet::Node
- Inherits:
-
Synchronization::Object
- Object
- Synchronization::AbstractObject
- Synchronization::Object
- Concurrent::Edge::LockFreeLinkedSet::Node
- Includes:
- Comparable
- Defined in:
- lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb
Instance Method Summary collapse
-
#<=>(other) ⇒ undocumented
We use
Object#hash
as a way to enforce ordering on the nodes. - #data ⇒ undocumented
-
#initialize(data = nil, successor = nil) ⇒ Node
constructor
A new instance of Node.
- #key ⇒ undocumented
-
#key_for(data) ⇒ undocumented
This method provides a unqiue key for the data which will be used for ordering.
-
#last? ⇒ Boolean
Check to see if the node is the last in the list.
-
#next_node ⇒ undocumented
Next node in the list.
- #successor_reference ⇒ undocumented
Constructor Details
#initialize(data = nil, successor = nil) ⇒ Node
Returns a new instance of Node.
11 12 13 14 15 16 |
# 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 Method Details
#<=>(other) ⇒ undocumented
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.
51 52 53 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 51 def <=>(other) @Key <=> other.hash end |
#data ⇒ undocumented
18 19 20 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 18 def data @Data end |
#key ⇒ undocumented
26 27 28 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 26 def key @Key end |
#key_for(data) ⇒ undocumented
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.
44 45 46 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 44 def key_for(data) data.hash end |
#last? ⇒ Boolean
Check to see if the node is the last in the list.
31 32 33 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 31 def last? @SuccessorReference.value.is_a? Tail end |
#next_node ⇒ undocumented
Next node in the list. Note: this is not the AtomicMarkableReference of the next node, this is the actual Node itself.
37 38 39 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 37 def next_node @SuccessorReference.value end |
#successor_reference ⇒ undocumented
22 23 24 |
# File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_linked_set/node.rb', line 22 def successor_reference @SuccessorReference end |