Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

This library *does* depend on thread (rubygems 1.6+ does not require …

…this for you)

Conflicts:

	lib/system_timer.rb
  • Loading branch information...
commit 4ee32e8db3a2e5a5aeaa419ab6568f44c9b274de 1 parent adc6ccc
Philippe Hanrigou ph7 authored

Showing 1 changed file with 15 additions and 14 deletions. Show diff stats Hide diff stats

  1. +15 14 lib/system_timer.rb
29 lib/system_timer.rb
@@ -5,6 +5,7 @@
5 5 else
6 6
7 7 require 'rubygems'
  8 +require 'thread'
8 9 require 'timeout'
9 10 require 'forwardable'
10 11 require 'monitor'
@@ -38,12 +39,12 @@ module SystemTimer
38 39 @timer_pool = ConcurrentTimerPool.new
39 40 @monitor = Monitor.new
40 41 end
41   -
  42 +
42 43 class << self
43   - attr_reader :timer_pool
44   -
45   - # Executes the method's block. If the block execution terminates before
46   - # +seconds+ seconds has passed, it returns true. If not, it terminates
  44 + attr_reader :timer_pool
  45 +
  46 + # Executes the method's block. If the block execution terminates before
  47 + # +seconds+ seconds has passed, it returns true. If not, it terminates
47 48 # the execution and raises a +Timeout::Error+.
48 49 def timeout_after(seconds, exception_class = nil)
49 50 new_timer = nil # just for scope
@@ -68,16 +69,16 @@ def timeout_after(seconds, exception_class = nil)
68 69 if next_interval
69 70 install_next_timer next_interval
70 71 else
71   - restore_original_configuration
  72 + restore_original_configuration
72 73 end
73 74 end
74 75 end
75   -
  76 +
76 77 # Backward compatibility with timeout.rb
77   - alias timeout timeout_after
78   -
  78 + alias timeout timeout_after
  79 +
79 80 protected
80   -
  81 +
81 82 def install_ruby_sigalrm_handler #:nodoc:
82 83 @original_ruby_sigalrm_handler = trap('SIGALRM') do
83 84 @monitor.synchronize do
@@ -86,17 +87,17 @@ def install_ruby_sigalrm_handler #:nodoc:
86 87 end
87 88 end
88 89 end
89   -
  90 +
90 91 def restore_original_ruby_sigalrm_handler #:nodoc:
91 92 trap('SIGALRM', original_ruby_sigalrm_handler || 'DEFAULT')
92 93 ensure
93 94 reset_original_ruby_sigalrm_handler
94 95 end
95   -
  96 +
96 97 def original_ruby_sigalrm_handler #:nodoc:
97 98 @original_ruby_sigalrm_handler
98 99 end
99   -
  100 +
100 101 def reset_original_ruby_sigalrm_handler #:nodoc:
101 102 @original_ruby_sigalrm_handler = nil
102 103 end
@@ -104,7 +105,7 @@ def reset_original_ruby_sigalrm_handler #:nodoc:
104 105 def debug(message) #:nodoc
105 106 puts message if debug_enabled?
106 107 end
107   -
  108 +
108 109 end
109 110
110 111 end

0 comments on commit 4ee32e8

Please sign in to comment.
Something went wrong with that request. Please try again.