Class: Rapns::Daemon::Pool

Inherits:
Object
  • Object
show all
Defined in:
lib/rapns/daemon/pool.rb

Direct Known Subclasses

DeliveryHandlerPool

Instance Method Summary collapse

Constructor Details

#initialize(num_objects) ⇒ Pool

Returns a new instance of Pool.



4
5
6
7
# File 'lib/rapns/daemon/pool.rb', line 4

def initialize(num_objects)
  @num_objects = num_objects
  @queue = Queue.new
end

Instance Method Details

#drainObject



17
18
19
20
21
22
# File 'lib/rapns/daemon/pool.rb', line 17

def drain
  while !@queue.empty?
    object = @queue.pop
    object_removed_from_pool(object)
  end
end

#populateObject



9
10
11
12
13
14
15
# File 'lib/rapns/daemon/pool.rb', line 9

def populate
  @num_objects.times do |i|
    object = new_object_for_pool(i)
    @queue.push(object)
    object_added_to_pool(object)
  end
end