Methods
Class Public methods
new()
Link
Instance Public methods
in(key)
Link
# 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)
Link
# 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