Parent

Files

Class/Module Index [+]

Quicksearch

Concurrent::Channel::BufferedChannel

@api Channel @!macro edge_warning

Public Class Methods

new(size) click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 10
def initialize(size)
  @mutex = Mutex.new
  @buffer_condition = ConditionVariable.new

  @probe_set = WaitableList.new
  @buffer = RingBuffer.new(size)
end

Public Instance Methods

buffer_queue_size() click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 22
def buffer_queue_size
  @mutex.synchronize { @buffer.count }
end
pop() click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 31
def pop
  probe = Channel::Probe.new
  select(probe)
  probe.value
end
probe_set_size() click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 18
def probe_set_size
  @probe_set.size
end
push(value) click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 26
def push(value)
  until set_probe_or_push_into_buffer(value)
  end
end
remove_probe(probe) click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 50
def remove_probe(probe)
  @probe_set.delete(probe)
end
select(probe) click to toggle source
# File lib/concurrent/channel/buffered_channel.rb, line 37
def select(probe)
  @mutex.synchronize do

    if @buffer.empty?
      @probe_set.put(probe)
      true
    else
      shift_buffer if probe.try_set([peek_buffer, self])
    end

  end
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.