Class: DriqDownstream

Inherits:
Driq
  • Object
show all
Defined in:
lib/driq.rb

Constant Summary

Constants inherited from Driq

Driq::VERSION

Instance Method Summary collapse

Methods inherited from Driq

#close, #last, #last_key, #read, #readpartial

Constructor Details

#initialize(upper, size = 100) ⇒ DriqDownstream

Returns a new instance of DriqDownstream.



78
79
80
81
82
# File 'lib/driq.rb', line 78

def initialize(upper, size=100)
  super(size)
  @upper = upper
  Thread.new { download }
end

Instance Method Details

#downloadObject



88
89
90
91
92
93
94
95
96
97
98
# File 'lib/driq.rb', line 88

def download
  while true
    ary = @upper.readpartial(@last, @ceil)
    synchronize do
      @list += ary
      @list = @list.last(@floor) if @list.size > @ceil
      @last = ary.last[0]
      @event.broadcast
    end
  end
end

#write(value) ⇒ Object



84
85
86
# File 'lib/driq.rb', line 84

def write(value)
  @upper.write(value)
end