Method: Concurrent::LockFreeStack#each

Defined in:
lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb

#each(head = nil) ⇒ self

Parameters:

  • head (Node) (defaults to: nil)

Returns:

  • (self)


107
108
109
110
111
112
113
114
115
# File 'lib/concurrent-ruby/concurrent/collection/lock_free_stack.rb', line 107

def each(head = nil)
  return to_enum(:each, head) unless block_given?
  it = head || peek
  until it.equal?(EMPTY)
    yield it.value
    it = it.next_node
  end
  self
end