ThreadError in SizedQueue#push


#1

e$B$$$^$$$G$9!#e(B

SizedQueue e$B$K;XDj$7$?e(B max e$B0J>e$N%*%V%8%’%/%H$re(B push
e$B$7$h$&$H$9$k$He(B
ThreadError
e$B$K$J$C$F$7$^$$$^$9!#K\Mh$O$=$3$G%V%m%C%/$5$l$k$s$8$c$J$$$+e(B
e$B$H;W$&$N$G$9$,!"$I$s$J$b$s$G$7$g$&$+!)e(B

$ ruby -rthread -ve’
q = SizedQueue.new(1)
2.times{q.push(nil)}

ruby 1.8.4 (2005-12-24) [i486-linux]
/usr/lib/ruby/1.8/thread.rb:426:in stop': stopping only thread (ThreadError) note: use sleep to stop forever from /usr/lib/ruby/1.8/thread.rb:426:inpush’
from -e:3
from -e:3

Thread.stop e$B$re(B sleep
e$B$K=q$-D>$9$H%V%m%C%/$7$F$/$l$k$h$&$K$J$j$^$9!#B>e(B
e$B$K$b2?%v=j$+e(B Thread.stop e$B$7$F$k$H$3$m$,$"$k$h$&$G$9!#e(B


#2

e$B$J$+$@$G$9!#e(B

At Fri, 2 Jun 2006 21:05:27 +0900,
Nobuhiro IMAI wrote in [ruby-dev:28678]:

SizedQueue e$B$K;XDj$7$?e(B max e$B0J>e$N%*%V%8%’%/%H$re(B push e$B$7$h$&$H$9$k$He(B
ThreadError e$B$K$J$C$F$7$^$$$^$9!#K\Mh$O$=$3$G%V%m%C%/$5$l$k$s$8$c$J$$$+e(B
e$B$H;W$&$N$G$9$,!"$I$s$J$b$s$G$7$g$&$+!)e(B

$ ruby -rthread -ve’
q = SizedQueue.new(1)
2.times{q.push(nil)}

e$BFI$_=P$9%9%l%C%I$,$$$J$$$N$K%V%m%C%/$9$k$H$$$&$3$H$O!"%G%C%I%m%Ce(B
e$B%/$H$$$&$3$H$@$H;W$$$^$9$,!#e(B


#3

e$B31$H$$$$$^$9!#e(B

On 2006/06/02, at 21:43, removed_email_address@domain.invalid wrote:

2.times{q.push(nil)}

e$BFI$_=P$9%9%l%C%I$,$$$J$$$N$K%V%m%C%/$9$k$H$$$&$3$H$O!"%G%C%I%m%Ce(B
e$B%/$H$$$&$3$H$@$H;W$$$^$9$,!#e(B

e$B$3$s$JIw$K;n$7$F$_$^$7$?!#e(B

cinq:~ mas$ irb --prompt simple -r thread

$q = SizedQueue.new(1)
=> #<SizedQueue:0x322be8 @waiting=[], @queue_wait=[], @max=1, @que=[]>

th = Thread.new { 2.times { $q.push(nil) }; ‘done’ }
=> #<Thread:0x31b960 sleep>

th
=> #<Thread:0x31b960 sleep>

$q.pop
=> nil

th
=> #<Thread:0x31b960 dead>

th.value
=> “done”


#4

e$B$$$^$$$G$9!#e(B

From: nobu_at_ruby-lang.org
Date: Fri, 2 Jun 2006 21:43:17 +0900

2.times{q.push(nil)}

e$BFI$_=P$9%9%l%C%I$,$$$J$$$N$K%V%m%C%/$9$k$H$$$&$3$H$O!"%G%C%I%m%Ce(B
e$B%/$H$$$&$3$H$@$H;W$$$^$9$,!#e(B

e$B3N$+$K%G%C%I%m%C%/$G$9$M!#FC$KL54X78$J%9%l%C%I$G$b!"B8:_$9$l$P%V%m%C%/e(B
e$B$O$9$k$s$G$9$M!#e(B

$ ruby -v -rthread -e’
Thread.start{sleep 5; puts “deadlock from now on”}
q = SizedQueue.new(1)
2.times{|i| q.push(i); p i}

ruby 1.8.4 (2005-12-24) [i486-linux]
0
deadlock from now on
(e$B0J9_%G%C%I%m%C%/e(B)

1 e$B9TL$Ge(B join
e$B$9$l$P85$N$HF1$8%(%i!<$K$J$j$^$7$?$,!"$9$G$K2?$,$7$?$$$+e(B
e$BJ,$+$i$J$/$J$C$F$-$?$N$G!"$3$NJU$G<:Ni$7$^$9!#$*A{$,$;$7$^$7$?!#e(B