Class: RefillingQueue

Inherits:
Object
  • Object
show all
Defined in:
lib/refilling_queue.rb,
lib/refilling_queue/version.rb

Defined Under Namespace

Classes: Locked

Constant Summary collapse

DEFAULT_OPTIONS =
{
  :lock_timeout => 60,
  :refresh_every => nil
}
VERSION =
'0.0.4'

Instance Method Summary collapse

Constructor Details

#initialize(client, name, options = {}, &block) ⇒ RefillingQueue

Returns a new instance of RefillingQueue.



12
13
14
15
16
# File 'lib/refilling_queue.rb', line 12

def initialize(client, name, options={}, &block)
  @client, @name, @block = client, name, block
  @options = DEFAULT_OPTIONS.merge(options)
  raise "Invalid keys" if (options.keys - DEFAULT_OPTIONS.keys).any?
end

Instance Method Details

#popObject



18
19
20
21
22
23
# File 'lib/refilling_queue.rb', line 18

def pop
  item = _pop
  return item unless item.nil?
  refill
  _pop
end