Method: Channel#read

Defined in:
lib/channel.rb

#readObject



51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/channel.rb', line 51

def read
  @mutex.synchronize {
    if @writing_thread 
      @writing_thread.wakeup
      @writing_thread = nil
    else 
      @reading_thread = Thread.current
      @mutex.sleep
      @reading_thread = nil
    end
    response = @value.shift
    @sender = response[:sender]
    response[:value]
  }
end