Class: RIO::Cmd::FibPipe

Inherits:
Object show all
Defined in:
lib/rio/fibpipe.rb

Direct Known Subclasses

From, To

Constant Summary collapse

@@depth =
0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fib) ⇒ FibPipe

Returns a new instance of FibPipe.



35
36
37
38
39
# File 'lib/rio/fibpipe.rb', line 35

def initialize(fib)
  @fib = fib
  @data = IOPair.new
  @source = nil
end

Instance Attribute Details

#fibObject (readonly)

Returns the value of attribute fib.



33
34
35
# File 'lib/rio/fibpipe.rb', line 33

def fib
  @fib
end

#sourceObject

Returns the value of attribute source.



34
35
36
# File 'lib/rio/fibpipe.rb', line 34

def source
  @source
end

Instance Method Details

#_fiber_init(trail) ⇒ Object



64
65
66
# File 'lib/rio/fibpipe.rb', line 64

def _fiber_init(trail)
  self.source = trail.shift
end

#dest_report_data_doneObject



61
62
63
# File 'lib/rio/fibpipe.rb', line 61

def dest_report_data_done
  fiber_yield nil
end

#dest_report_new_dataObject



58
59
60
# File 'lib/rio/fibpipe.rb', line 58

def dest_report_new_data
  fiber_yield true
end

#dest_wait_for_readerObject



51
52
53
54
55
56
57
# File 'lib/rio/fibpipe.rb', line 51

def dest_wait_for_reader
  while ans = fiber_yield(nil)
    p "   #{self.class}: Waiting #{ans.inspect}"
    sleep 1
    #break

  end
end

#fiber_yield(*args) ⇒ Object



47
48
49
50
# File 'lib/rio/fibpipe.rb', line 47

def fiber_yield(*args)
  @@depth -= 1
  Fiber.yield(*args)
end

#resume(*args) ⇒ Object



40
41
42
# File 'lib/rio/fibpipe.rb', line 40

def resume(*args) 
  fib.resume(*args)
end

#source_resume(*args) ⇒ Object



43
44
45
46
# File 'lib/rio/fibpipe.rb', line 43

def source_resume(*args)
  @@depth += 1
  source.resume(*args)
end