diff options
author | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-06-04 09:02:30 +0000 |
---|---|---|
committer | (no author) <(no author)@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-06-04 09:02:30 +0000 |
commit | 469c1f3f40f279906aceceb7cd4aef80eeffd642 (patch) | |
tree | 37d0caae0cb84f774c364bfa2077423a31144e5f /lib/thread.rb | |
parent | 99020d6e50702eb371111d73280eb80b4b29ba5b (diff) |
This commit was manufactured by cvs2svn to create tag 'v1_6_4'.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/tags/v1_6_4@1498 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/thread.rb')
-rw-r--r-- | lib/thread.rb | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/lib/thread.rb b/lib/thread.rb index d4b6ad6ec1..0537c78650 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -74,7 +74,10 @@ class Mutex retry end Thread.critical = false - t.run if t + begin + t.run if t + rescue ThreadError + end self end @@ -160,7 +163,10 @@ class Queue ensure Thread.critical = false end - t.run if t + begin + t.run if t + rescue ThreadError + end end def enq(obj) push(obj) @@ -170,7 +176,7 @@ class Queue Thread.critical = true begin loop do - if @que.length == 0 + if @que.empty? if non_block raise ThreadError, "queue empty" end @@ -184,13 +190,11 @@ class Queue Thread.critical = false end end - def shift(non_block=false) - pop(non_block=false) - end - alias deq shift + alias shift pop + alias deq pop def empty? - @que.length == 0 + @que.empty? end def clear @@ -223,11 +227,11 @@ class SizedQueue<Queue def max=(max) Thread.critical = true - if max >= @max + if max <= @max @max = max Thread.critical = false else - diff = max - @max + diff = @max - max @max = max Thread.critical = false diff.times do @@ -253,6 +257,7 @@ class SizedQueue<Queue end def pop(*args) + retval = super Thread.critical = true if @que.length < @max begin @@ -263,9 +268,12 @@ class SizedQueue<Queue ensure Thread.critical = false end - t.run if t + begin + t.run if t + rescue ThreadError + end end - super + retval end def num_waiting |