Class: Uma::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/uma/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Server

Returns a new instance of Server.



8
9
10
# File 'lib/uma/server.rb', line 8

def initialize(env)
  @env = env
end

Instance Method Details

#startObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/uma/server.rb', line 12

def start
  @machine = UM.new
  @stop_queue = UM::Queue.new

  @config = ServerControl.server_config(@env)
  @threads = @config[:thread_count].times.map {
    ServerControl.start_worker_thread(@config, @stop_queue)
  }

  ServerControl.await_process_termination(@machine)

  stop
end

#stopObject



26
27
28
29
30
31
32
# File 'lib/uma/server.rb', line 26

def stop
  return if !@threads

  @config[:thread_count].times { @machine.push(@stop_queue, :stop) }
  @threads.each(&:join)
  @threads = nil
end