1 # -*- encoding: binary -*-
6 # Actor concurrency model for Rubinius. We can't seem to get message
7 # passing working right, so we're throwing a Mutex into the mix for
8 # now. Hopefully somebody can fix things for us.
10 # This is different from the Revactor one which is not prone to race
11 # conditions at all (since it uses Fibers).
15 # runs inside each forked worker, this sits around and waits
16 # for connections and doesn't die until the parent dies (or is
17 # given a INT, QUIT, or TERM signal)
18 def worker_loop(worker)
19 init_worker_process(worker)
20 limit = worker_connections
23 # can't seem to get the message passing to work right at the moment :<
27 ret = IO.select(LISTENERS, nil, nil, 1) and ret.first.each do |l|
28 lock.synchronize { nr >= limit } and break sleep(0.01)
29 c = Rainbows.accept(l) and Actor.spawn do
30 lock.synchronize { nr += 1 }
34 lock.synchronize { nr -= 1 }
40 end while G.tick || lock.synchronize { nr > 0 }