Permalink
Browse files

Renamed instance variable to reflect the fact that we now use a monitor

  • Loading branch information...
1 parent ed90ff9 commit c529a26adf0965197513e4e95e8f7b96536dcc41 @ph7 ph7 committed Jan 19, 2010
Showing with 24 additions and 9 deletions.
  1. +8 −1 ChangeLog
  2. +10 −2 README
  3. +6 −6 lib/system_timer.rb
View
@@ -1,4 +1,11 @@
-=== 1.1.3/ 2009-29-11
+=== 1.1.4/ 2010-01-18
+
+ * Changed from using Mutex to Monitor. Evidently Mutex causes thread join
+ errors when Ruby is compiled with -disable-pthreads
+ (Contributed by [Dmytro Shteflyuk](http://kpumuk.info/))
+
+
+=== 1.1.3/ 2009-11-29
* Preparing GemCutter migration
View
12 README
@@ -35,8 +35,16 @@ a convenience shell wrapping a simple call to timeout.rb under the cover.
== Authors
* David Vollbracht <http://davidvollbracht.com>
-* Philippe Hanrigou <http:/ph7spot.com>
-
+* Philippe Hanrigou <http://ph7spot.com>
+
+== Contributor
+
+* Dmytro Shteflyuk <http://kpumuk.info/> :
+
+ - Changed from using Mutex to Monitor. Evidently Mutex causes thread
+ join errors when Ruby is compiled with -disable-pthreads
+ <http://github.com/ph7/system-timer/commit/50cfbb1177e2163295d34649e98205a3a26dc451>
+
== Copyright
Copyright:: (C) 2008 David Vollbracht & Philippe Hanrigou
View
@@ -30,9 +30,9 @@
#
module SystemTimer
- Thread.exclusive do # Avoid race conditions for mutex and pool creation
+ Thread.exclusive do # Avoid race conditions for monitor and pool creation
@timer_pool = ConcurrentTimerPool.new
- @mutex = Monitor.new
+ @monitor = Monitor.new
end
class << self
@@ -43,7 +43,7 @@ class << self
# the execution and raises a +Timeout::Error+.
def timeout_after(seconds)
new_timer = nil # just for scope
- @mutex.synchronize do
+ @monitor.synchronize do
new_timer = timer_pool.add_timer seconds
timer_interval = timer_pool.next_trigger_interval_in_seconds
debug "==== Install Timer ==== at #{Time.now.to_i}, next interval: #{timer_interval}"
@@ -55,7 +55,7 @@ def timeout_after(seconds)
end
return yield
ensure
- @mutex.synchronize do
+ @monitor.synchronize do
debug "==== Cleanup Timer ==== at #{Time.now.to_i}, #{new_timer} "
timer_pool.cancel new_timer
timer_pool.log_registered_timers if debug_enabled?
@@ -76,7 +76,7 @@ def timeout_after(seconds)
def install_ruby_sigalrm_handler #:nodoc:
@original_ruby_sigalrm_handler = trap('SIGALRM') do
- @mutex.synchronize do
+ @monitor.synchronize do
# Triggers timers one at a time to ensure more deterministic results
timer_pool.trigger_next_expired_timer
end
@@ -105,4 +105,4 @@ def debug(message) #:nodoc
end
-require 'system_timer_native'
+require 'system_timer_native'

0 comments on commit c529a26

Please sign in to comment.