diff options
Diffstat (limited to 'lib/yahns/queue_egg.rb')
-rw-r--r-- | lib/yahns/queue_egg.rb | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/yahns/queue_egg.rb b/lib/yahns/queue_egg.rb new file mode 100644 index 0000000..a2abc2f --- /dev/null +++ b/lib/yahns/queue_egg.rb @@ -0,0 +1,23 @@ +# Copyright (C) 2013, Eric Wong <normalperson@yhbt.net> and all contributors +# License: GPLv3 or later (https://www.gnu.org/licenses/gpl-3.0.txt) + +# this represents a Yahns::Queue before its vivified. This only +# lives in the parent process and should be clobbered after qc_vivify +class Yahns::QueueEgg # :nodoc: + attr_writer :max_events, :worker_threads + attr_accessor :logger + + def initialize + @max_events = 1 # 1 is good if worker_threads > 1 + @worker_threads = 7 # any default is wrong for most apps... + @logger = nil + end + + # only call after forking + def qc_vivify(fdmap) + queue = Yahns::Queue.new + queue.fdmap = fdmap + queue.spawn_worker_threads(@logger, @worker_threads, @max_events) + queue + end +end |