On Sun, 3 May 2009, Devyn Cairns wrote:

> Oh, and it flickers a lot before it dies.
> 
> On Sun, May 3, 2009 at 9:03 AM, Devyn Cairns <[email protected]> wrote:
> > What do you mean? This is what it does for me:
> > (attached)
> >
> > On Sat, May 2, 2009 at 10:53 PM, Len Lawrence <[email protected]> 
> > wrote:
> >> Devyn Cairns wrote:
> >>>
> >>> Stumbled on this by accident. Try this and see what you get:
> >>>
> >>>    Shoes.app do
> >>>        Thread.start do
> >>>            400.times { para '', :stroke => black }
> >>>        end
> >>>    end
> >>>
> >>> --
> >>>   ~devyn
> >>>

I've tried to put some diagnostics around this, to repeat the process
till it blows up but tell you about how far it got.  This is on the basis
that it would allow us to compare the bugs across platforms better.

Threads in Ruby 1.8 are supposed to be in process.  I've closed the
shoes app, had the cmd window associated with it disappear, and then
had a load of shoes windows pop up afterwards.  Once a window
containing the number 499 popped up but there is no way I've seen
400 windows come and go. 

Anyway, here is the code.  Maybe someone else can make it behave.

#!shoes
#
# 

require 'thread'

Shoes.app do

  def new_app(count)
    win = window do 
      stack do
        owner.replace_label "Threads to start"
        th = Thread.start do
          count.times { para '', :stroke => black }
        end
        th.join
        owner.replace_label "Threads done"
      end
    end
    
    while not win.started()
      owner.replace_label "win not started"
      sleep 1
    end
    sleep 1
    return win
  end

  Thread.abort_on_exception=true
  @mutex = Mutex.new
  @count = 0
  @mutex.synchronize do 
    @label = para "#...@count}"
  end

  def replace_label str
    @mutex.synchronize do 
      @label.replace "#{count} " + str
    end
  end

  clipboard = @count
  500.times do |i|
    @count = i 
    replace_label ""
    win = new_app(@count)
    replace_label "got window"
    sleep 5
    win.close
  end
end

 
#       Hugh

Reply via email to