diff options
author | Eric Wong <normalperson@yhbt.net> | 2010-02-11 22:15:29 -0800 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2010-02-11 22:23:40 -0800 |
commit | de6b5dd5ffff6e21064f78f24c30c59e391ff370 (patch) | |
tree | dbb55da2b6b18f176aac3296e4327cc0fefad5ec /lib/rainbows | |
parent | 71b8fff3d8d171c9770bb8c69767341c10d9c962 (diff) | |
download | rainbows-de6b5dd5ffff6e21064f78f24c30c59e391ff370.tar.gz |
When available (Ruby 1.9), we can use Hash#compare_by_identity to improve performance.
Diffstat (limited to 'lib/rainbows')
-rw-r--r-- | lib/rainbows/fiber/base.rb | 6 | ||||
-rw-r--r-- | lib/rainbows/rev.rb | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/rainbows/fiber/base.rb b/lib/rainbows/fiber/base.rb index 090a9e4..c65b07b 100644 --- a/lib/rainbows/fiber/base.rb +++ b/lib/rainbows/fiber/base.rb @@ -5,13 +5,13 @@ module Rainbows module Fiber # blocked readers (key: Rainbows::Fiber::IO object, value is irrelevant) - RD = {} + RD = {}.compare_by_identity # blocked writers (key: Rainbows::Fiber::IO object, value is irrelevant) - WR = {} + WR = {}.compare_by_identity # sleeping fibers go here (key: Fiber object, value: wakeup time) - ZZ = {} + ZZ = {}.compare_by_identity # puts the current Fiber into uninterruptible sleep for at least # +seconds+. Unlike Kernel#sleep, this it is not possible to sleep diff --git a/lib/rainbows/rev.rb b/lib/rainbows/rev.rb index 197d138..6650c2b 100644 --- a/lib/rainbows/rev.rb +++ b/lib/rainbows/rev.rb @@ -31,6 +31,11 @@ module Rainbows # all connected clients CONN = {} + if {}.respond_to?(:compare_by_identity) + CONN.compare_by_identity + KATO.compare_by_identity + end + include Core end end |