Class: Browserly::Pool

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/browserly/pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePool

Returns a new instance of Pool.



8
9
10
11
# File 'lib/browserly/pool.rb', line 8

def initialize
  @browsers = SizedQueue.new(Browserly.configuration.pool_size)
  Browserly.configuration.pool_size.times { @browsers.push(new_browser) }
end

Instance Attribute Details

#browsersObject (readonly)

Returns the value of attribute browsers.



6
7
8
# File 'lib/browserly/pool.rb', line 6

def browsers
  @browsers
end

Instance Method Details

#release!(browser) ⇒ Object



17
18
19
# File 'lib/browserly/pool.rb', line 17

def release!(browser)
  @browsers.push(browser)
end

#take_browserObject



13
14
15
# File 'lib/browserly/pool.rb', line 13

def take_browser
  @browsers.pop
end

#terminate_all!Object



21
22
23
# File 'lib/browserly/pool.rb', line 21

def terminate_all!
  @browsers.each(&:quit)
end