diff options
author | Eric Wong <normalperson@yhbt.net> | 2013-10-28 06:52:36 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2013-10-28 06:52:36 +0000 |
commit | a667bc3787eaaf5b7df3b70624985d5fb5b8fc61 (patch) | |
tree | 7b364453627e2bdc4b737c5310abb8755f69222c /lib/yahns/server.rb | |
parent | 64dc231c557426f5729ad3b8b3d5a6693ca85ad2 (diff) | |
download | yahns-a667bc3787eaaf5b7df3b70624985d5fb5b8fc61.tar.gz |
We do not want users to use the default queue unless an app context requires it. We also do not want to spin up the default queue unless we are sure we have app contexts using it (and not private/anonymous queues).
Diffstat (limited to 'lib/yahns/server.rb')
-rw-r--r-- | lib/yahns/server.rb | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/lib/yahns/server.rb b/lib/yahns/server.rb index 9a72ef5..fea310c 100644 --- a/lib/yahns/server.rb +++ b/lib/yahns/server.rb @@ -307,6 +307,15 @@ class Yahns::Server # :nodoc: $0 = ([ File.basename(s[0]), tag ]).concat(s[:argv]).join(' ') end + def qegg_vivify(qegg, fdmap) + queue = qegg.vivify(fdmap) + qegg.worker_threads.times do + @wthr << queue.worker_thread(@logger, qegg.max_events) + end + @queues << queue + queue + end + # spins up processing threads of the server def fdmap_init thresh = @config.value(:client_expire_threshold) @@ -314,16 +323,8 @@ class Yahns::Server # :nodoc: # keeps track of all connections, like ObjectSpace, but only for IOs fdmap = Yahns::Fdmap.new(@logger, thresh) - # initialize queues (epoll/kqueue) and associated worker threads + # once initialize queues (epoll/kqueue) and associated worker threads queues = {} - @config.qeggs.each do |name, qe| - queue = qe.vivify(fdmap) - qe.worker_threads.times do - @wthr << queue.worker_thread(@logger, qe.max_events) - end - @queues << queue - queues[qe] = queue - end # spin up applications (which are preload: false) @config.app_ctx.each(&:after_fork_init) @@ -334,7 +335,7 @@ class Yahns::Server # :nodoc: qegg = ctx.qegg || @config.qeggs[:default] # acceptors feed the the queues - l.spawn_acceptor(@logger, ctx, queues[qegg]) + l.spawn_acceptor(@logger, ctx, queues[qegg] ||= qegg_vivify(qegg, fdmap)) end fdmap end |