Created
December 6, 2010 17:22
-
-
Save phiggins/730598 to your computer and use it in GitHub Desktop.
comm_inactivity_timeout
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'eventmachine' | |
# Code adapted from here: | |
# https://github.com/eventmachine/eventmachine/blob/master/tests/test_inactivity_timeout.rb#L36 | |
start, finish = nil | |
timeout_handler = Module.new do | |
define_method :unbind do | |
finish = Time.now | |
EM.stop | |
end | |
end | |
EM.run { | |
EM.heartbeat_interval = 0.1 | |
EM.start_server("127.0.0.1", 12345) | |
EM.add_timer(0.1) { | |
start = Time.now | |
c = EM.connect("127.0.0.1", 12345, timeout_handler) | |
c.comm_inactivity_timeout = 0.2 | |
} | |
} | |
puts finish - start | |
# linux | |
# $ ruby -Ilib test_inactivity_timeout.rb | |
# 0.200822293 | |
# | |
# winxp | |
# >ruby -Ilib test_inactivity_timeout.rb | |
# 200.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment