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 recieve and pull. pull must cause 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.
-
#pull ⇒ Object
pull must cause thread blocking when it is empty.
-
#recieve(data) ⇒ Object
Emit data to pipe.
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
#pull ⇒ Object
pull must cause thread blocking when it is empty.
24 25 26 |
# File 'lib/datapipes/pipe.rb', line 24 def pull @queue.deq end |
#recieve(data) ⇒ Object
Emit data to pipe.
19 20 21 |
# File 'lib/datapipes/pipe.rb', line 19 def recieve(data) @queue.enq data end |