Permalink
Browse files

Do not invoke scheduler thread when it won't be used.

For 1.9 & JRuby.
  • Loading branch information...
nahi committed Apr 7, 2011
1 parent 9e7290b commit 95f2457a254b1c75a181806029d6463799561bc6
Showing with 9 additions and 5 deletions.
  1. +2 −0 lib/httpclient/timeout.rb
  2. +7 −5 test/test_httpclient.rb
@@ -23,6 +23,7 @@ class HTTPClient
# timeout scheduler.
# * Do not wakeup the scheduler thread so often. Let scheduler thread sleep
# until the nearest period.
+if !defined?(JRUBY_VERSION) and RUBY_VERSION < '1.9'
class TimeoutScheduler
# Represents timeout period.
@@ -117,6 +118,7 @@ def timeout_scheduler
end
end
timeout_scheduler # initialize at first time.
+end
module Timeout
if !defined?(JRUBY_VERSION) and RUBY_VERSION < '1.9'
View
@@ -1147,11 +1147,13 @@ def test_response
end
end
- def test_timeout_scheduler
- assert_equal('hello', @client.get_content(@url + 'hello'))
- status = HTTPClient.timeout_scheduler.instance_eval { @thread.kill; @thread.join; @thread.status }
- assert(!status) # dead
- assert_equal('hello', @client.get_content(@url + 'hello'))
+ if !defined?(JRUBY_VERSION) and RUBY_VERSION < '1.9'
+ def test_timeout_scheduler
+ assert_equal('hello', @client.get_content(@url + 'hello'))
+ status = HTTPClient.timeout_scheduler.instance_eval { @thread.kill; @thread.join; @thread.status }
+ assert(!status) # dead
+ assert_equal('hello', @client.get_content(@url + 'hello'))
+ end
end
def test_session_manager

0 comments on commit 95f2457

Please sign in to comment.