Method: Authorize::ResourcePool#initialize

Defined in:
lib/authorize/resource_pool.rb

#initialize(max_size, factory) ⇒ ResourcePool

Create a new unfilled resource pool with a capacity of of at most max_size objects. The pool is lazily filled by the factory lambda.



17
18
19
20
21
22
23
24
25
# File 'lib/authorize/resource_pool.rb', line 17

def initialize(max_size, factory)
  @factory = factory
  @pool = []
  @tokens = []
  @monitor = Monitor.new
  @tokens_cv = @monitor.new_cond
  @num_waiting = 0
  max_size.times {|i| @tokens.unshift(i)}
end