transferred Code Ocean from original repository to GitHub

This commit is contained in:
Hauke Klement
2015-01-22 09:51:49 +01:00
commit 4cbf9970b1
683 changed files with 11979 additions and 0 deletions

16
lib/port_pool.rb Normal file
View File

@@ -0,0 +1,16 @@
class PortPool
PORT_RANGE = DockerClient.config[:ports]
@available_ports = PORT_RANGE.to_a
@mutex = Mutex.new
def self.available_port
@mutex.synchronize do
@available_ports.delete(@available_ports.sample)
end
end
def self.release(port)
@available_ports << port if PORT_RANGE.include?(port) && !@available_ports.include?(port)
end
end