From: Steve Tuckner Date: 2002-12-04T08:03:00+09:00 Subject: FW: Fox threading issues This is a multi-part message in MIME format. ------=_NextPart_000_0352_01C29AED.C5DC48F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Also the version of fox on linux is 1.0.26 and FXRuby is 1.0.14. On Windows it is whatever is with the 1.6.7 Ruby Central installer. -----Original Message----- From: Steve Tuckner Sent: Tuesday, December 03, 2002 5:01 PM To: ruby-talk@ruby-lang.org Subject: Fox threading issues I have a simple program (down below) that causes different failures on the 1.6.7 MSC build (from RubyCentral) and on Linux with 1.6.7. On Windows the program just locks up. On Linux (as on cygwin) it runs for a while and then seg faults. Any ideas anyone? Steve Tuckner require "thread" require "fox" include Fox class MainWindow < FXMainWindow def initialize(app) # Invoke base class initialize first super(app, "Main Window", nil, nil, DECOR_ALL, 0, 0, 400, 200) menubar = FXMenubar.new(self, LAYOUT_SIDE_TOP|LAYOUT_FILL_X) # File Menu filemenu = FXMenuPane.new(self) FXMenuCommand.new(filemenu, "&Quit", nil, getApp(), FXApp::ID_QUIT, 0) FXMenuTitle.new(menubar, "&File", nil, filemenu) label = FXLabel.new(self, "Count: ") @countLabel = FXLabel.new(self, "0") button = FXButton.new(self, "Reset Count") button.connect(SEL_COMMAND) do $count = 0 end end def onTimeout(sender, sel, ptr) $lock.synchronize { @countLabel.setText($count.to_s) } getApp().addTimeout(100, method(:onTimeout)) end def create super show(PLACEMENT_SCREEN) getApp().addTimeout(100, method(:onTimeout)) end end $count = 0 $lock = Mutex.new w = Thread.new do loop do #File.open("thrd.rb", "r") do |f| #data = f.read #end $lock.synchronize { $count += 1 } sleep 0 end end # Make an application application = FXApp.new("Dialog", "FoxTest") application.init(ARGV) MainWindow.new(application) application.create application.run ------=_NextPart_000_0352_01C29AED.C5DC48F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Also=20 the version of fox on linux is 1.0.26 and FXRuby is 1.0.14. On Windows = it is=20 whatever is with the 1.6.7 Ruby Central installer.
-----Original Message-----
From: Steve Tuckner=20
Sent: Tuesday, December 03, 2002 5:01 PM
To:=20 ruby-talk@ruby-lang.org
Subject: Fox threading=20 issues

I = have a simple=20 program (down below) that causes different failures on the 1.6.7 = MSC=20 build (from RubyCentral) and on Linux with 1.6.7. On Windows the = program just=20 locks up. On Linux (as on cygwin) it runs for a while and then seg = faults. Any=20 ideas anyone?
 
Steve=20 Tuckner
 
require=20 "thread"
require "fox"
 
include=20 Fox
 
class MainWindow=20 < FXMainWindow
  def initialize(app)
  # Invoke = base class=20 initialize first
  super(app, "Main Window", nil, nil, = DECOR_ALL, 0,=20 0, 400, 200)
 
  menubar =3D FXMenubar.new(self,=20 LAYOUT_SIDE_TOP|LAYOUT_FILL_X)
 
  # File = Menu
 =20 filemenu =3D FXMenuPane.new(self)
  = FXMenuCommand.new(filemenu,=20 "&Quit", nil, getApp(), FXApp::ID_QUIT, 0)
 =20 FXMenuTitle.new(menubar, "&File", nil, = filemenu)
 
  label=20 =3D FXLabel.new(self, "Count: ")
  @countLabel =3D = FXLabel.new(self,=20 "0")
 
  button =3D FXButton.new(self, "Reset = Count")
 =20 button.connect(SEL_COMMAND) do
   $count =3D 0
  = end
 end
 
   def onTimeout(sender, sel, = ptr)
  $lock.synchronize { 
     = @countLabel.setText($count.to_s)
    }
 =20 getApp().addTimeout(100, method(:onTimeout))
  =20 end
  
 def create
  super
 =20 show(PLACEMENT_SCREEN)
  getApp().addTimeout(100,=20 method(:onTimeout))
 end
end
 
 
$count =3D=20 0
$lock =3D Mutex.new
 
w =3D Thread.new = do
 loop=20 do
 #File.open("thrd.rb", "r") do |f|
   #data = =3D=20 f.read
   #end
 
  $lock.synchronize = { =20
   $count +=3D 1
  }
  sleep=20 0
 end
end
 
# Make an = application
application =3D=20 FXApp.new("Dialog",=20 = "FoxTest")
application.init(ARGV)
MainWindow.new(application)
a= pplication.create
application.run
 
 
------=_NextPart_000_0352_01C29AED.C5DC48F0--