class Qpid::Proton::Container::SelectWaker

Selectable object that can be used to wake IO.select from another thread

Public Class Methods

new() click to toggle source
# File lib/core/container.rb, line 334
def initialize
  @rd, @wr = IO.pipe
  @lock = Mutex.new
  @set = false
end

Public Instance Methods

close() click to toggle source
# File lib/core/container.rb, line 358
def close
  @rd.close
  @wr.close
end
reset() click to toggle source
# File lib/core/container.rb, line 350
def reset
  @lock.synchronize do
    return unless @set
    @rd.read_nonblock(1) rescue nil
    @set = false
  end
end
to_io() click to toggle source
# File lib/core/container.rb, line 340
def to_io() @rd; end
wake() click to toggle source
# File lib/core/container.rb, line 342
def wake
  @lock.synchronize do
    return if @set        # Don't write if already has data
    @set = true
    @wr.write_nonblock('x') rescue nil
  end
end