Class: Hyperion::ServerPool
- Inherits:
-
Object
- Object
- Hyperion::ServerPool
- Defined in:
- lib/hyperion_test/server_pool.rb
Instance Method Summary collapse
- #check_in(s) ⇒ Object
- #check_out ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ ServerPool
constructor
A new instance of ServerPool.
Constructor Details
#initialize ⇒ ServerPool
Returns a new instance of ServerPool.
3 4 5 6 |
# File 'lib/hyperion_test/server_pool.rb', line 3 def initialize @free = [] @in_use = [] end |
Instance Method Details
#check_in(s) ⇒ Object
14 15 16 17 |
# File 'lib/hyperion_test/server_pool.rb', line 14 def check_in(s) @in_use.delete(s) @free.push(s) end |
#check_out ⇒ Object
8 9 10 11 12 |
# File 'lib/hyperion_test/server_pool.rb', line 8 def check_out s = @free.pop || FakeServer.new(next_port) @in_use.push(s) s end |
#clear ⇒ Object
19 20 21 22 23 24 |
# File 'lib/hyperion_test/server_pool.rb', line 19 def clear all = @free + @in_use all.each(&:teardown) @free = [] @in_use = [] end |