diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-03-17 08:58:21 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2000-03-17 08:58:21 +0000 |
commit | 5c13dd59db1ee6c04cdac4ce2ee97d5934115439 (patch) | |
tree | b7027454a641e7c51404b316cb9b0b28f66acd3d /lib/thread.rb | |
parent | d8f981b972aab02d1432abe1c9cadf0507945e77 (diff) |
2000-03-17
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@646 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/thread.rb')
-rw-r--r-- | lib/thread.rb | 53 |
1 files changed, 40 insertions, 13 deletions
diff --git a/lib/thread.rb b/lib/thread.rb index 22610f2992..9edda48abe 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -63,10 +63,14 @@ class Mutex def unlock return unless @locked Thread.critical = true - t = @waiting.shift @locked = false + begin + t = @waiting.shift + t.wakeup if t + rescue ThreadError + retry + end Thread.critical = false - t.run if t self end @@ -82,9 +86,13 @@ class Mutex def exclusive_unlock return unless @locked Thread.exclusive do - t = @waiting.shift @locked = false - t.wakeup if t + begin + t = @waiting.shift + t.wakeup if t + rescue ThreadError + retry + end yield end self @@ -105,8 +113,12 @@ class ConditionVariable end def signal - t = @waiters.shift - t.run if t + begin + t = @waiters.shift + t.run if t + rescue ThreadError + retry + end end def broadcast @@ -116,7 +128,10 @@ class ConditionVariable @waiters.clear end for t in waiters0 - t.run + begin + t.run + rescue ThreadError + end end end end @@ -133,9 +148,13 @@ class Queue def push(obj) Thread.critical = true @que.push obj - t = @waiting.shift + begin + t = @waiting.shift + t.wakeup if t + rescue ThreadError + retry + end Thread.critical = false - t.run if t end alias enq push @@ -201,8 +220,12 @@ class SizedQueue<Queue @max = max Thread.critical = false diff.times do - t = @queue_wait.shift - t.run if t + begin + t = @queue_wait.shift + t.run if t + rescue ThreadError + retry + end end end max @@ -221,8 +244,12 @@ class SizedQueue<Queue def pop(*args) Thread.critical = true if @que.length < @max - t = @queue_wait.shift - t.run if t + begin + t = @queue_wait.shift + t.run if t + rescue ThreadError + retry + end end super end |