Methods
I
N
O
Class Public methods
new()
# File sample/drb/simpletuple.rb, line 9
def initialize
  @hash = {}
  @waiting = {}
  @hash.taint
  @waiting.taint
  self.taint
end
Instance Public methods
in(key)
# File sample/drb/simpletuple.rb, line 33
def in(key)
  Thread.critical = true
  @hash[key] ||= []
  @waiting[key] ||= []
  begin
    loop do
      if @hash[key].length == 0
        @waiting[key].push Thread.current
        Thread.stop
      else
        return @hash[key].shift
      end
    end
  ensure
    @hash.delete(key) if @hash[key].length == 0
    Thread.critical = false
  end
end
out(key, obj)
# File sample/drb/simpletuple.rb, line 17
def out(key, obj)
  Thread.critical = true
  @hash[key] ||= []
  @waiting[key] ||= []
  @hash[key].push obj
  begin
    t = @waiting[key].shift
    @waiting.delete(key) if @waiting[key].length == 0
    t.wakeup if t
  rescue ThreadError
    retry
  ensure
    Thread.critical = false
  end
end