* lib/thread.rb (Queue::pop): get rid of race condition.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2527 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6956135b4b
commit
d760f97172
@ -1,3 +1,7 @@
|
|||||||
|
Thu Jun 6 11:42:15 2002 Nobuyoshi Nakada <nobu.nokada@softhome.net>
|
||||||
|
|
||||||
|
* lib/thread.rb (Queue::pop): get rid of race condition.
|
||||||
|
|
||||||
Tue Jun 4 18:28:37 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
Tue Jun 4 18:28:37 2002 WATANABE Hirofumi <eban@ruby-lang.org>
|
||||||
|
|
||||||
* ext/socket/extconf.rb: The IPv6 stack of Cygwin is still incomplete.
|
* ext/socket/extconf.rb: The IPv6 stack of Cygwin is still incomplete.
|
||||||
|
@ -173,22 +173,14 @@ class Queue
|
|||||||
alias enq push
|
alias enq push
|
||||||
|
|
||||||
def pop(non_block=false)
|
def pop(non_block=false)
|
||||||
Thread.critical = true
|
while (Thread.critical = true; @que.empty?)
|
||||||
begin
|
raise ThreadError, "queue empty" if non_block
|
||||||
loop do
|
@waiting.push Thread.current
|
||||||
if @que.empty?
|
Thread.stop
|
||||||
if non_block
|
|
||||||
raise ThreadError, "queue empty"
|
|
||||||
end
|
|
||||||
@waiting.push Thread.current
|
|
||||||
Thread.stop
|
|
||||||
else
|
|
||||||
return @que.shift
|
|
||||||
end
|
|
||||||
end
|
|
||||||
ensure
|
|
||||||
Thread.critical = false
|
|
||||||
end
|
end
|
||||||
|
@que.shift
|
||||||
|
ensure
|
||||||
|
Thread.critical = false
|
||||||
end
|
end
|
||||||
alias shift pop
|
alias shift pop
|
||||||
alias deq pop
|
alias deq pop
|
||||||
|
Loading…
x
Reference in New Issue
Block a user