Module: DTAS::WritableIter

Included in:
Pipe
Defined in:
lib/dtas/writable_iter.rb

Overview

used to manage writable state for -player pipes

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#on_writableObject

:nodoc:



8
9
10
# File 'lib/dtas/writable_iter.rb', line 8

def on_writable
  @on_writable
end

#ready_writeObject

we may use the ready_write flag to avoid an extra IO.select



10
11
12
# File 'lib/dtas/writable_iter.rb', line 10

def ready_write
  @ready_write
end

Instance Method Details

#ready_write_optimized?Boolean

Returns:

  • (Boolean)


18
19
20
21
22
# File 'lib/dtas/writable_iter.rb', line 18

def ready_write_optimized?
  rv = @ready_write
  @ready_write = false
  rv
end

#wait_writable_prepareObject



24
25
26
27
# File 'lib/dtas/writable_iter.rb', line 24

def wait_writable_prepare
  @ready_write = false
  @on_writable ||= @mark_writable
end

#writable_iterObject

this is used to exchange our own writable status for the readable status of the DTAS::Buffer which triggered us.



31
32
33
34
35
36
37
38
# File 'lib/dtas/writable_iter.rb', line 31

def writable_iter
  if owr = @on_writable
    @on_writable = nil
    @ready_write = true
    owr.call # this triggers readability watching of DTAS::Buffer
  end
  :ignore
end

#writable_iter_initObject



12
13
14
15
16
# File 'lib/dtas/writable_iter.rb', line 12

def writable_iter_init
  @mark_writable = proc { @ready_write = true }
  @on_writable = nil
  @ready_write = true
end