rainbows.git  about / heads / tags
Unicorn for sleepy apps and slow clients
blob 8cb839d26d6f0397a34b2f77ccb0aa68a969424c 1102 bytes (raw)
$ git show v0.95.1:lib/rainbows/actor_spawn.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
24
25
26
27
28
29
 
# -*- encoding: binary -*-

require 'actor'
module Rainbows

  # Actor concurrency model for Rubinius.  We can't seem to get message
  # passing working right, so we're throwing a Mutex into the mix for
  # now.  Hopefully somebody can fix things for us.  Currently, this is
  # exactly the same as the ThreadSpawn model since we don't use the
  # message passing capabilities of the Actor model (and even then
  # it wouldn't really make sense since Actors in Rubinius are just
  # Threads underneath and our ThreadSpawn model is one layer of
  # complexity less.
  #
  # This is different from the Revactor one which is not prone to race
  # conditions within the same process at all (since it uses Fibers).
  module ActorSpawn
    include ThreadSpawn

    # runs inside each forked worker, this sits around and waits
    # for connections and doesn't die until the parent dies (or is
    # given a INT, QUIT, or TERM signal)
    def worker_loop(worker) # :nodoc:
      Const::RACK_DEFAULTS["rack.multithread"] = true # :(
      init_worker_process(worker)
      accept_loop(Actor)
    end
  end
end

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