Class: Rapns::Daemon::Pool
- Inherits:
-
Object
- Object
- Rapns::Daemon::Pool
- Defined in:
- lib/rapns/daemon/pool.rb
Direct Known Subclasses
Instance Method Summary collapse
- #drain ⇒ Object
-
#initialize(num_objects) ⇒ Pool
constructor
A new instance of Pool.
- #populate ⇒ Object
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
#drain ⇒ Object
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 |
#populate ⇒ Object
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 |