Class: Carbon::Reader::FetchQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/carbon/reader.rb

Instance Method Summary collapse

Constructor Details

#initializeFetchQueue

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

#shiftObject



31
32
33
# File 'lib/carbon/reader.rb', line 31

def shift
  @queue.shift
end