yahns.git  about / heads / tags
sleepy, multi-threaded, non-blocking application server for Ruby
blob a2abc2f1146c17b260e44bf2e05300a5433638e7 736 bytes (raw)
$ git show v0.0.0:lib/yahns/queue_egg.rb	# shows this blob on the CLI

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
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

git clone git://yhbt.net/yahns.git
git clone https://yhbt.net/yahns.git