Module: DTAS::WritableIter

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

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#on_writableObject

Returns the value of attribute on_writable.



6
7
8
# File 'lib/dtas/writable_iter.rb', line 6

def on_writable
  @on_writable
end

#ready_writeObject

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



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

def ready_write
  @ready_write
end

Instance Method Details

#ready_write_optimized?Boolean

Returns:

  • (Boolean)


16
17
18
19
20
# File 'lib/dtas/writable_iter.rb', line 16

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

#wait_writable_prepareObject



22
23
24
25
# File 'lib/dtas/writable_iter.rb', line 22

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.



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

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



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

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