Class: Qpid::Proton::Container::SelectWaker
- Inherits:
-
Object
- Object
- Qpid::Proton::Container::SelectWaker
- Defined in:
- lib/core/container.rb
Overview
Selectable object that can be used to wake IO.select from another thread
Instance Method Summary collapse
- #close
-
#initialize ⇒ SelectWaker
constructor
A new instance of SelectWaker.
- #reset
- #to_io
- #wake
Constructor Details
#initialize ⇒ SelectWaker
Returns a new instance of SelectWaker.
334 335 336 337 338 |
# File 'lib/core/container.rb', line 334 def initialize @rd, @wr = IO.pipe @lock = Mutex.new @set = false end |
Instance Method Details
#close
358 359 360 361 |
# File 'lib/core/container.rb', line 358 def close @rd.close @wr.close end |
#reset
350 351 352 353 354 355 356 |
# 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
340 |
# File 'lib/core/container.rb', line 340 def to_io() @rd; end |
#wake
342 343 344 345 346 347 348 |
# 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 |