Class: Peons::Queue

Inherits:
Nest
  • Object
show all
Defined in:
lib/peons.rb

Instance Method Summary collapse

Instance Method Details

#backupObject



30
31
32
# File 'lib/peons.rb', line 30

def backup
  self[Process.pid][:backup]
end

#eachObject



22
23
24
25
26
27
28
# File 'lib/peons.rb', line 22

def each
  catch :empty do
    loop do
      pop! { |e| yield e }
    end
  end
end

#errorsObject



34
35
36
# File 'lib/peons.rb', line 34

def errors
  self[:errors]
end

#popObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/peons.rb', line 10

def pop
  return unless item = rpoplpush(backup)

  begin
    yield item
  rescue Exception => e
    fail(e, item)
  ensure
    backup.del
  end
end