Parent

Included Modules

Files

Class/Module Index [+]

Quicksearch

Concurrent::Edge::LockFreeStack

Constants

EMPTY

Public Class Methods

new() click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 24
def initialize
  @Head = AtomicReference.new EMPTY
  ensure_ivar_visibility!
end

Public Instance Methods

clear() click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 63
def clear
  while true
    head = @Head.get
    return false if head == EMPTY
    return true if @Head.compare_and_set head, EMPTY
  end
end
compare_and_clear(head) click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 59
def compare_and_clear(head)
  @Head.compare_and_set head, EMPTY
end
compare_and_pop(head) click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 48
def compare_and_pop(head)
  @Head.compare_and_set head, head.next_node
end
compare_and_push(head, value) click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 33
def compare_and_push(head, value)
  @Head.compare_and_set head, Node[value, head]
end
each() click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 73
def each
  return to_enum unless block_given?
  it = peek
  until it.equal?(EMPTY)
    yield it.value
    it = it.next_node
  end
  self
end
empty?() click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 29
def empty?
  @Head.get.equal? EMPTY
end
peek() click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 44
def peek
  @Head.get
end
pop() click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 52
def pop
  while true
    head = @Head.get
    return head.value if @Head.compare_and_set head, head.next_node
  end
end
push(value) click to toggle source
# File lib/concurrent/edge/lock_free_stack.rb, line 37
def push(value)
  while true
    head = @Head.get
    return self if @Head.compare_and_set head, Node[value, head]
  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.