Delay client thread if user thread is the first.

This commit is contained in:
Martin Edenhofer 2012-08-04 11:38:18 +02:00
parent 7e7885343e
commit 5c5372c888

View file

@ -69,7 +69,9 @@ module Session
next if !user next if !user
# start user thread # start user thread
start_user_thread = false
if !@@user_threads[user.id] if !@@user_threads[user.id]
start_user_thread = true
@@user_threads[user.id] = Thread.new { @@user_threads[user.id] = Thread.new {
UserState.new(user.id) UserState.new(user.id)
@@user_threads[user.id] = nil @@user_threads[user.id] = nil
@ -77,6 +79,11 @@ module Session
} }
end end
# wait with client thread unil user thread has done some little work
if start_user_thread
sleep 0.4
end
# start client thread # start client thread
if !@@client_threads[client_id] if !@@client_threads[client_id]
@@client_threads[client_id] = Thread.new { @@client_threads[client_id] = Thread.new {