Class: Hyperion::ServerPool

Inherits:
Object
  • Object
show all
Defined in:
lib/hyperion_test/server_pool.rb

Instance Method Summary collapse

Constructor Details

#initializeServerPool

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_outObject



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

#clearObject



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