Class: Concurrent::LockFreeQueue::Node — Concurrent Ruby

# Class: Concurrent::LockFreeQueue::Node

Inherits:
  Synchronization::Object
  - Object
  - Synchronization::Object
  - Concurrent::LockFreeQueue::Node
  show all

Defined in:
  lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb

## Instance Method Summary collapse

- #compare_and_set_successor(expected_successor, new_successor) ⇒ true, false

  Sets the successor to new_successor if the current successor is expected_successor.

- #initialize(item, successor) ⇒ Node constructor

  A new instance of Node.

- #item ⇒ undocumented
- #successor ⇒ Object

  The successor.

- #successor=(new_successor) ⇒ Object

  Set the successor.

- #swap_successor(new_successor) ⇒ Object

  Set the successor to new_successor and return the old successor.

- #update_successor {|Object| ... } ⇒ Object

  Updates the successor using the block.

## Constructor Details

### #initialize(item, successor) ⇒ `Node`

Returns a new instance of Node.

    9
    10
    11
    12
    13
    14
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 9

    def initialize(item, successor)
      super()
      # published through queue, no need to be volatile or final
      @Item          = item
      self.successor = successor
    end

## Instance Method Details

### #compare_and_set_successor(expected_successor, new_successor) ⇒ `true`, `false`

Sets the successor to new_successor if the current successor is expected_successor

Returns:

- (`true`, `false`)

    7
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 7

    attr_atomic :successor

### #item ⇒ `undocumented`

    16
    17
    18
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 16

    def item
      @Item
    end

### #successor ⇒ `Object`

Returns The successor.

Returns:

- (`Object`) —

  The successor.

    7
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 7

    attr_atomic :successor

### #successor=(new_successor) ⇒ `Object`

Set the successor.

Returns:

- (`Object`) —

  new_successor.

    7
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 7

    attr_atomic :successor

### #swap_successor(new_successor) ⇒ `Object`

Set the successor to new_successor and return the old successor.

Returns:

- (`Object`) —

  old successor

    7
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 7

    attr_atomic :successor

### #update_successor {|Object| ... } ⇒ `Object`

Updates the successor using the block.

Yields:

- (`Object`) —

  Calculate a new successor using given (old) successor

Yield Parameters:

- old (`Object`) —

  successor

Returns:

- (`Object`) —

  new successor

    7
    # File 'lib/concurrent-ruby-edge/concurrent/edge/lock_free_queue.rb', line 7

    attr_atomic :successor