Class: Metasploit::Aggregator::EnumeratorQueue

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/metasploit/aggregator.rb

Overview

A EnumeratorQueue wraps a Queue to yield the items added to it.

Instance Method Summary collapse

Constructor Details

#initialize(sentinel) ⇒ EnumeratorQueue

Returns a new instance of EnumeratorQueue.



257
258
259
260
# File 'lib/metasploit/aggregator.rb', line 257

def initialize(sentinel)
  @q = Queue.new
  @sentinel = sentinel
end

Instance Method Details

#each_itemObject



262
263
264
265
266
267
268
269
270
# File 'lib/metasploit/aggregator.rb', line 262

def each_item
  return enum_for(:each_item) unless block_given?
  loop do
    r = @q.pop
    break if r.equal?(@sentinel)
    fail r if r.is_a? Exception
    yield r
  end
end