Class: Datapipes::Pipe
- Inherits:
-
Object
- Object
- Datapipes::Pipe
- Defined in:
- lib/datapipes/pipe.rb
Overview
Pipe is not only data pipeline but handling asynchronous.
You can make your own pipe with database or something, but becareful this object used in multi thread.
If you make your own, you can override initialize, because this is not used in internal.
Then supply pour_in and pour_out. pour_out must occur thread blocking when it is empty.
Instance Method Summary collapse
-
#initialize ⇒ Pipe
constructor
You can override and don’t need to call super in sub class.
-
#pour_in(data) ⇒ Object
Emit data to pipe.
-
#pour_out ⇒ Object
pour_out must cause thread blocking when it is empty.
Constructor Details
#initialize ⇒ Pipe
You can override and don’t need to call super in sub class.
14 15 16 |
# File 'lib/datapipes/pipe.rb', line 14 def initialize @queue ||= Queue.new end |
Instance Method Details
#pour_in(data) ⇒ Object
Emit data to pipe.
19 20 21 |
# File 'lib/datapipes/pipe.rb', line 19 def pour_in(data) @queue.enq data end |
#pour_out ⇒ Object
pour_out must cause thread blocking when it is empty.
24 25 26 |
# File 'lib/datapipes/pipe.rb', line 24 def pour_out @queue.deq end |