Sha256: 7f5a1c25ce848a54d23f73b32fa28fee574e86c72725bffbdd04feef538a6f26
Contents?: true
Size: 1.12 KB
Versions: 4
Compression:
Stored size: 1.12 KB
Contents
module VncTools class ServerPool include Observable def initialize(capacity, klass = Server) @capacity = capacity @servers = Array.new(capacity) { klass.new } @running = [] end def stop running.each do |s| fire :on_display_stopping, s s.stop end end def size @servers.size end def get raise OutOfDisplaysError if @servers.empty? server = next_server fire :on_display_fetched, server server end def release(server) raise TooManyDisplaysError if size == @capacity fire :on_display_released, server @servers.unshift server end private def fire(*args) changed notify_observers(*args) end def running @running end def next_server server = @servers.shift if server.display.nil? fire :on_display_starting, server server.start @running << server end server end class TooManyDisplaysError < StandardError end class OutOfDisplaysError < StandardError end end # DisplayPool end # CukeForker
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
vnctools-0.0.4 | lib/vnctools/server_pool.rb |
vnctools-0.0.3 | lib/vnctools/server_pool.rb |
vnctools-0.0.2 | lib/vnctools/server_pool.rb |
vnctools-0.0.1 | lib/vnctools/server_pool.rb |