summaryrefslogtreecommitdiff
path: root/lib/thread.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/thread.rb')
-rw-r--r--lib/thread.rb22
1 files changed, 7 insertions, 15 deletions
diff --git a/lib/thread.rb b/lib/thread.rb
index a3983174615..7666bccecf7 100644
--- a/lib/thread.rb
+++ b/lib/thread.rb
@@ -173,22 +173,14 @@ class Queue
alias enq push
def pop(non_block=false)
- Thread.critical = true
- begin
- loop do
- if @que.empty?
- if non_block
- raise ThreadError, "queue empty"
- end
- @waiting.push Thread.current
- Thread.stop
- else
- return @que.shift
- end
- end
- ensure
- Thread.critical = false
+ while (Thread.critical = true; @que.empty?)
+ raise ThreadError, "queue empty" if non_block
+ @waiting.push Thread.current
+ Thread.stop
end
+ @que.shift
+ ensure
+ Thread.critical = false
end
alias shift pop
alias deq pop