diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-05-20 09:19:51 +0000 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-05-20 09:21:18 +0000 |
commit | ea6d0eab436c78113f8a61e7fcc34db4117d14c0 (patch) | |
tree | d70b0bd67e444997f4122c246ce438dc449242ce /lib/rainbows/xepoll_thread_pool/client.rb | |
parent | 90af18f6884857704d72fd6b2bb91718aad72117 (diff) | |
download | rainbows-ea6d0eab436c78113f8a61e7fcc34db4117d14c0.tar.gz |
In concurrency models long keepalive times are cheap (and thus more likely to be used), this allows Rainbows! to gracefully shut down more quickly.
Diffstat (limited to 'lib/rainbows/xepoll_thread_pool/client.rb')
-rw-r--r-- | lib/rainbows/xepoll_thread_pool/client.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/rainbows/xepoll_thread_pool/client.rb b/lib/rainbows/xepoll_thread_pool/client.rb index b33998d..2cf05e5 100644 --- a/lib/rainbows/xepoll_thread_pool/client.rb +++ b/lib/rainbows/xepoll_thread_pool/client.rb @@ -37,11 +37,15 @@ module Rainbows::XEpollThreadPool::Client ep = SleepyPenguin::Epoll EP = ep.new - Rainbows.at_quit { EP.close } IN = ep::IN | ep::ET | ep::ONESHOT KATO = {} KATO.compare_by_identity if KATO.respond_to?(:compare_by_identity) LOCK = Mutex.new + Rainbows.at_quit do + clients = nil + LOCK.synchronize { clients = KATO.keys; KATO.clear } + clients.each { |io| io.closed? or io.close } + end @@last_expire = Time.now def kato_set |