Delay client thread if user thread is the first.
This commit is contained in:
parent
7e7885343e
commit
5c5372c888
1 changed files with 7 additions and 0 deletions
|
@ -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 {
|
||||||
|
|
Loading…
Reference in a new issue