Class: Carbon::Reader::FetchQueue
- Inherits:
-
Object
- Object
- Carbon::Reader::FetchQueue
- Defined in:
- lib/carbon/reader.rb
Instance Method Summary collapse
-
#initialize ⇒ FetchQueue
constructor
A new instance of FetchQueue.
- #on_push(&block) ⇒ Object
- #push(value) ⇒ Object
- #shift ⇒ Object
Constructor Details
#initialize ⇒ FetchQueue
Returns a new instance of FetchQueue.
20 21 22 |
# File 'lib/carbon/reader.rb', line 20 def initialize @queue = [] end |
Instance Method Details
#on_push(&block) ⇒ Object
35 36 37 |
# File 'lib/carbon/reader.rb', line 35 def on_push(&block) @on_push = block end |
#push(value) ⇒ Object
24 25 26 27 28 29 |
# File 'lib/carbon/reader.rb', line 24 def push(value) EM::next_tick do @queue.push(value) @on_push[] end end |
#shift ⇒ Object
31 32 33 |
# File 'lib/carbon/reader.rb', line 31 def shift @queue.shift end |