diff options
author | Eric Wong <normalperson@yhbt.net> | 2009-11-28 19:42:53 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2009-11-29 12:35:44 -0800 |
commit | 37a560c5d14c15a3da7f2c10c9ea3d6002b34fe1 (patch) | |
tree | 8d163646e4ba3586cafde788804c580e3315431c /lib/rainbows/actor_spawn.rb | |
parent | 50fb5151bd44137adace51a0652f4d01d851790c (diff) | |
download | rainbows-37a560c5d14c15a3da7f2c10c9ea3d6002b34fe1.tar.gz |
It's a tad faster for non-keepalive connections and should do better on large SMP machines with many workers AND threads. That means the ActorSpawn model in Rubinius is nothing more than ThreadSpawn underneath (for now).
Diffstat (limited to 'lib/rainbows/actor_spawn.rb')
-rw-r--r-- | lib/rainbows/actor_spawn.rb | 33 |
1 files changed, 9 insertions, 24 deletions
diff --git a/lib/rainbows/actor_spawn.rb b/lib/rainbows/actor_spawn.rb index 2662f9f..98e85bc 100644 --- a/lib/rainbows/actor_spawn.rb +++ b/lib/rainbows/actor_spawn.rb @@ -5,12 +5,17 @@ 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. + # 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 at all (since it uses Fibers). + # conditions within the same process at all (since it uses Fibers). module ActorSpawn - include Base + include ThreadSpawn # runs inside each forked worker, this sits around and waits # for connections and doesn't die until the parent dies (or is @@ -18,27 +23,7 @@ module Rainbows def worker_loop(worker) Const::RACK_DEFAULTS["rack.multithread"] = true # :( init_worker_process(worker) - limit = worker_connections - nr = 0 - - # can't seem to get the message passing to work right at the moment :< - lock = Mutex.new - - begin - ret = IO.select(LISTENERS, nil, nil, 1) and ret.first.each do |l| - lock.synchronize { nr >= limit } and break sleep(0.01) - c = Rainbows.accept(l) and Actor.spawn do - lock.synchronize { nr += 1 } - begin - process_client(c) - ensure - lock.synchronize { nr -= 1 } - end - end - end - rescue => e - Error.listen_loop(e) - end while G.tick || lock.synchronize { nr > 0 } + accept_loop(Actor) end end end |