From: info@... Date: 2003-01-22T18:26:50+09:00 Subject: Question regarding threads and perhaps YAML This is a multi-part message in MIME format. ------=_NextPart_000_006B_01C2C1B5.4DDCC2F0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Hi, I am learning ruby and writing my first non-trivial program and I'm running into a few issues. First of all, I am having problems getting threading to work consistently. I am simply having the thread execute a code block which loads a YAML file into a ruby object. The thread completes when the file is an empty file (just a dash), but when the file has YAML code, the thread just never seems to lock at that part of the code. When I join it later it does complete properly. Here is the simple code example: loadingthread = Thread.new('maps/currentmap.yml') { |filename| puts "starting thread" mapfile = File.open(filename) puts "opened file" amap = YAML::load(mapfile) puts "generated object" mapfile.close puts "thread all done" } Any advice for a ruby-newbie would be appreciated :) ------=_NextPart_000_006B_01C2C1B5.4DDCC2F0 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Hi, I = am learning=20 ruby and writing my first non-trivial program and I'm running into a few = issues.
 
First = of all, I am=20 having problems getting threading to work consistently. I am simply = having the=20 thread execute a code block which loads a YAML file into a = ruby=20 object. The thread completes when the file is an empty file (just a = dash), but=20 when the file has YAML code, the thread just never seems to lock at that = part of=20 the code. When I join it later it does complete properly. Here is the = simple=20 code example:
 
 loadingthread=20 =3D Thread.new('maps/currentmap.yml') { = |filename|
    =20 puts "starting thread"
     mapfile =3D=20 File.open(filename)
     puts "opened=20 file"
     amap =3D=20 YAML::load(mapfile)
     puts "generated=20 object"
     = mapfile.close
    =20 puts "thread all done"
 }
 
Any = advice for a=20 ruby-newbie would be appreciated :)
------=_NextPart_000_006B_01C2C1B5.4DDCC2F0--