Class: Browserly::Pool
- Inherits:
-
Object
- Object
- Browserly::Pool
- Includes:
- Singleton
- Defined in:
- lib/browserly/pool.rb
Instance Attribute Summary collapse
-
#browsers ⇒ Object
readonly
Returns the value of attribute browsers.
Instance Method Summary collapse
-
#initialize ⇒ Pool
constructor
A new instance of Pool.
- #release!(browser) ⇒ Object
- #take_browser ⇒ Object
- #terminate_all! ⇒ Object
Constructor Details
#initialize ⇒ Pool
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
#browsers ⇒ Object (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_browser ⇒ Object
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 |