diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-03-03 02:39:35 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1998-03-03 02:39:35 +0000 |
commit | 0861165bdcef50bb504526153d87d8e0a7be0140 (patch) | |
tree | 41d899ef727f1b9adbb8efdb349eb4853eb2db62 /lib/thread.rb | |
parent | 6bb525282cdd551bd240557daf019378ee211952 (diff) |
*** empty log message ***
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/v1_1r@105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/thread.rb')
-rw-r--r-- | lib/thread.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/thread.rb b/lib/thread.rb index 91c588f603..709aa83c25 100644 --- a/lib/thread.rb +++ b/lib/thread.rb @@ -59,8 +59,8 @@ class Mutex end def synchronize + lock begin - lock yield ensure unlock @@ -115,22 +115,22 @@ class Queue end def pop non_block=false - item = nil - until item - Thread.critical = true - if @que.length == 0 - if non_block - Thread.critical = false - raise ThreadError, "queue empty" + Thread.critical = true + begin + loop do + if @que.length == 0 + if non_block + raise ThreadError, "queue empty" + end + @waiting.push Thread.current + Thread.stop + else + return @que.shift end - @waiting.push Thread.current - Thread.stop - else - item = @que.shift end + ensure + Thread.critical = false end - Thread.critical = false - item end def empty? |