SystemTimer 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,8 @@
1
+ === 1.2.3 / 2011-03-19
2
+
3
+ - Fix for RubyGems 1.6
4
+ (Contributed by James Tucker <http://blog.ra66i.org>)
5
+
1
6
  === 1.2.2 / 2011-01-25
2
7
 
3
8
  * Explicit required_ruby_version = '~> 1.8.7' in gem spec.
@@ -5,7 +10,7 @@
5
10
 
6
11
  === 1.2.1 / 2010-11-15
7
12
 
8
- * Better Rubinious support (Contributed by
13
+ * Better Rubinious support (Contributed by
9
14
  Evan Phoenix <http://blog.fallingsnow.net/>)
10
15
 
11
16
  === 1.2 / 2010-02-25
@@ -17,7 +22,7 @@
17
22
  * Timeouts can now be specified as a float and be a fraction of a second.
18
23
  e.g. `SystemTimer.timeout(0.5)`
19
24
  (Based on a contribution by Dmytro Shteflyuk <http://kpumuk.info/>)
20
-
25
+
21
26
  * Added support for custom timeout exception. Useful to avoid interference
22
27
  with other libraries using `Timeout::Error` (e.g. `Net::HTTP`)
23
28
  (Contributed by runix <http://github.com/runix>)
@@ -33,8 +38,8 @@
33
38
  === 1.1.1 / 2009-03-10
34
39
 
35
40
  * Fixing set_itimerval_with_minimum_1s_interval method signature
36
- which was incorrect and resulted in a segfault on 64 bits
37
- platform (int versus VALUE). Thanks to Mike Perham for
41
+ which was incorrect and resulted in a segfault on 64 bits
42
+ platform (int versus VALUE). Thanks to Mike Perham for
38
43
  investigating the problem and sending the patch!
39
44
 
40
45
  === 1.1.0 / 2008-11-05
@@ -45,7 +50,7 @@
45
50
  Thread.new do
46
51
  SystemTimer.timeout_after(5) do
47
52
  sleep 60
48
- puts "hi there!"
53
+ puts "hi there!"
49
54
  end
50
55
  end
51
56
  end
data/README CHANGED
@@ -11,16 +11,16 @@ More background on:
11
11
  * [http://ph7spot.com/musings/system-timer](http://ph7spot.com/musings/system-timer)
12
12
  * [http://davidvollbracht.com/2008/6/2/30-days-of-teach-day-1-systemtimer](http://davidvollbracht.com/2008/6/2/30-days-of-teach-day-1-systemtimer)
13
13
 
14
- Usage
14
+ Usage
15
15
  =====
16
16
 
17
17
  require 'system_timer'
18
-
18
+
19
19
  SystemTimer.timeout_after(5) do
20
-
20
+
21
21
  # Something that should be interrupted if it takes too much time...
22
22
  # ... even if blocked on a system call!
23
-
23
+
24
24
  end
25
25
 
26
26
  Timeouts as Floats
@@ -29,16 +29,16 @@ Usage
29
29
  You can use a floating point number when specifying the timeout in
30
30
  seconds but SystemTimer will not allow you to go below 200ms, e.g.
31
31
 
32
- SystemTimer.timeout_after(0.5) do
32
+ SystemTimer.timeout_after(0.5) do
33
33
  # timeout after 500ms
34
34
  end
35
35
 
36
- SystemTimer.timeout_after(0.01) do
36
+ SystemTimer.timeout_after(0.01) do
37
37
  # timeout after (uncompressable) 200ms even if 10ms is requested
38
38
  end
39
39
 
40
- Note that SystemTimer is going through too many layers to be
41
- able to reliably guarantee a sub-second timeout on all platforms,
40
+ Note that SystemTimer is going through too many layers to be
41
+ able to reliably guarantee a sub-second timeout on all platforms,
42
42
  so your mileage may vary when specifying timeouts under one second.
43
43
 
44
44
  Custom Timeout Exceptions
@@ -48,14 +48,14 @@ Usage
48
48
  avoid interference with other libraries using `Timeout::Error` -- e.g. `Net::HTTP`)
49
49
 
50
50
  require 'system_timer'
51
-
51
+
52
52
  begin
53
53
 
54
54
  SystemTimer.timeout_after(5, MyCustomTimeoutException) do
55
-
55
+
56
56
  # Something that should be interrupted if it takes too much time...
57
57
  # ... even if blocked on a system call!
58
-
58
+
59
59
  end
60
60
 
61
61
  rescue MyCustomTimeoutException => e
@@ -67,7 +67,7 @@ Requirements
67
67
  ============
68
68
 
69
69
  SystemTimer only works on UNIX platforms (Mac OS X, Linux, Solaris, BSD, ...).
70
- You can install the gem on Microsoft Windows, but you will only get
70
+ You can install the gem on Microsoft Windows, but you will only get
71
71
  a convenience shell wrapping a simple call to timeout.rb under the cover.
72
72
 
73
73
  Install
@@ -87,20 +87,25 @@ Contributors
87
87
  * Dmytro Shteflyuk <http://kpumuk.info/> :
88
88
  - Changed from using Mutex to Monitor. Evidently Mutex causes thread
89
89
  join errors when Ruby is compiled with -disable-pthreads
90
- <http://github.com/kpumuk/system-micro-timer/commit/fe28f4dcf7d4126e53b7c642c5ec35fe8bc1e081>
90
+ <https://github.com/kpumuk/system-micro-timer/commit/fe28f4dcf7d4126e53b7c642c5ec35fe8bc1e081>
91
91
  - First tentative to support float timeouts
92
- <http://github.com/kpumuk/system-micro-timer/commit/57fff73849aad7c94f8b9234352b7288d1314d21>
92
+ <https://github.com/kpumuk/system-micro-timer/commit/57fff73849aad7c94f8b9234352b7288d1314d21>
93
93
 
94
94
  * runix <http://github.com/runix> :
95
95
  - Added support for custom timeout exception. Useful to avoid interference
96
96
  with other libraries using `Timeout::Error` (e.g. `Net::HTTP`)
97
- <http://github.com/runix/system-timer/commit/d33acb3acc53d5105c68b25c3a2126fa682f12c0>
98
- <http://github.com/runix/system-timer/commit/d8ca3452e462ea909d8e11a6091e7c30dfa3a1a8>
97
+ <https://github.com/runix/system-timer/commit/d33acb3acc53d5105c68b25c3a2126fa682f12c0>
98
+ <https://github.com/runix/system-timer/commit/d8ca3452e462ea909d8e11a6091e7c30dfa3a1a8>
99
99
 
100
100
  * Jesse Storimer <http://jstorimer.com>
101
101
  - Explicit required_ruby_version = '~> 1.8.7' in gem spec.
102
102
  <https://github.com/jstorimer/system-timer/commit/ec08b4d2173ffd635065a1680c8f8b4fbf6691fd>
103
103
 
104
+ * James Tucker <http://blog.ra66i.org>
105
+ - Fix for RubyGems 1.6, which will not require "thread"
106
+ <https://github.com/raggi/system-timer/commit/f6dd9535e3f1141f319fe7919b8347dd0e40560c>
107
+ <https://github.com/raggi/system-timer/commit/b13ff12bc7392b1aa2fe7911e305a3e8f215efd2>
108
+
104
109
  Copyright
105
110
  =========
106
111
 
@@ -123,14 +128,14 @@ David Vollbracht and Philippe Hanrigou pair programmed an alternative
123
128
  implementation based on system timers (the +SIGALRM+ POSIX signal):
124
129
  This design guarantees proper timeout behavior even when crossing-boundaries and accessing
125
130
  system/external resources. Special care has been taken to interfere as little as
126
- possible with other processes that might also rely on +SIGALRM+,
131
+ possible with other processes that might also rely on +SIGALRM+,
127
132
  in particular MySQL.
128
133
 
129
134
  This implementation is not intended to be drop-in replacement to
130
- timeout.rb, just a way to wrap sensitive call to system resources.
135
+ timeout.rb, just a way to wrap sensitive call to system resources.
131
136
 
132
- You can find more details on SystemTimer and how to use it
133
- at http://ph7spot.com/articles/system_timer
137
+ You can find more details on SystemTimer and how to use it
138
+ at http://ph7spot.com/articles/system_timer
134
139
 
135
140
  License
136
141
  =======
@@ -186,9 +191,9 @@ You can redistribute it and/or modify it under either the terms of the GPL
186
191
  files under the ./missing directory. See each file for the copying
187
192
  condition.
188
193
 
189
- 5. The scripts and library files supplied as input to or produced as
194
+ 5. The scripts and library files supplied as input to or produced as
190
195
  output from the software do not automatically fall under the
191
- copyright of the software, but belong to whomever generated them,
196
+ copyright of the software, but belong to whomever generated them,
192
197
  and may be sold commercially, and may be aggregated with this
193
198
  software.
194
199
 
@@ -4,7 +4,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == "rbx"
4
4
  require File.dirname(__FILE__) + '/system_timer_stub'
5
5
  else
6
6
 
7
- require 'rubygems'
7
+ require 'thread'
8
8
  require 'timeout'
9
9
  require 'forwardable'
10
10
  require 'monitor'
@@ -38,12 +38,12 @@ module SystemTimer
38
38
  @timer_pool = ConcurrentTimerPool.new
39
39
  @monitor = Monitor.new
40
40
  end
41
-
41
+
42
42
  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
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
47
47
  # the execution and raises a +Timeout::Error+.
48
48
  def timeout_after(seconds, exception_class = nil)
49
49
  new_timer = nil # just for scope
@@ -56,7 +56,7 @@ module SystemTimer
56
56
  else
57
57
  install_next_timer timer_interval
58
58
  end
59
- end
59
+ end
60
60
  return yield
61
61
  ensure
62
62
  @monitor.synchronize do
@@ -68,16 +68,16 @@ module SystemTimer
68
68
  if next_interval
69
69
  install_next_timer next_interval
70
70
  else
71
- restore_original_configuration
71
+ restore_original_configuration
72
72
  end
73
73
  end
74
74
  end
75
-
75
+
76
76
  # Backward compatibility with timeout.rb
77
- alias timeout timeout_after
78
-
77
+ alias timeout timeout_after
78
+
79
79
  protected
80
-
80
+
81
81
  def install_ruby_sigalrm_handler #:nodoc:
82
82
  @original_ruby_sigalrm_handler = trap('SIGALRM') do
83
83
  @monitor.synchronize do
@@ -86,17 +86,17 @@ module SystemTimer
86
86
  end
87
87
  end
88
88
  end
89
-
89
+
90
90
  def restore_original_ruby_sigalrm_handler #:nodoc:
91
91
  trap('SIGALRM', original_ruby_sigalrm_handler || 'DEFAULT')
92
92
  ensure
93
93
  reset_original_ruby_sigalrm_handler
94
94
  end
95
-
95
+
96
96
  def original_ruby_sigalrm_handler #:nodoc:
97
97
  @original_ruby_sigalrm_handler
98
98
  end
99
-
99
+
100
100
  def reset_original_ruby_sigalrm_handler #:nodoc:
101
101
  @original_ruby_sigalrm_handler = nil
102
102
  end
@@ -104,7 +104,7 @@ module SystemTimer
104
104
  def debug(message) #:nodoc
105
105
  puts message if debug_enabled?
106
106
  end
107
-
107
+
108
108
  end
109
109
 
110
110
  end
@@ -1,6 +1,5 @@
1
1
  # Copyright 2008 David Vollbracht & Philippe Hanrigou
2
2
 
3
- require 'rubygems'
4
3
  require 'timeout'
5
4
 
6
5
  module SystemTimer
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: SystemTimer
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 2
9
- - 2
10
- version: 1.2.2
9
+ - 3
10
+ version: 1.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Philippe Hanrigou
@@ -16,7 +16,7 @@ autorequire: system_timer
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-01-25 00:00:00 -08:00
19
+ date: 2011-03-19 00:00:00 -07:00
20
20
  default_executable:
21
21
  dependencies: []
22
22