Hello
How do to write a synchronized class like in java for Ruby
I try with a Mutex but if a method call another method of the same
instance I obtain a Deadlock.
Thanks
Guillaume
···
--
Posted via http://www.ruby-forum.com/.
Hello
How do to write a synchronized class like in java for Ruby
I try with a Mutex but if a method call another method of the same
instance I obtain a Deadlock.
Thanks
Guillaume
--
Posted via http://www.ruby-forum.com/.
I wrote a reentrant mutex class at one point in time ...
Give it a shot and see if it fixes your deadlock issue.
Blessings,
TwP
On Thu, May 7, 2009 at 6:38 AM, Guillaume dorchies <guillaume.dorchies@gmail.com> wrote:
Hello
How do to write a synchronized class like in java for Ruby
I try with a Mutex but if a method call another method of the same
instance I obtain a Deadlock.
Thank you It's exactly that I need
--
Posted via http://www.ruby-forum.com/.
Sorry, but you could have saved yourself the effort because it's part
of the standard library:
17:45:59 $ ruby19 -r monitor -e 'm=Monitor.new;m.synchronize {
m.synchronize { p 1 } }'
1
17:46:05 $ ruby19 -r thread -e 'm=Mutex.new;m.synchronize {
m.synchronize { p 1 } }'
<internal:prelude>:6:in `lock': deadlock; recursive locking (ThreadError)
from <internal:prelude>:6:in `synchronize'
from -e:1:in `block in <main>'
from <internal:prelude>:8:in `synchronize'
from -e:1:in `<main>'
17:46:17 $ ruby19 -r monitor -e 'm=Monitor.new;m.synchronize {
m.synchronize { p 1 } }'
1
17:46:23 $
Kind regards
robert
2009/5/7 Tim Pease <tim.pease@gmail.com>:
On Thu, May 7, 2009 at 6:38 AM, Guillaume dorchies > <guillaume.dorchies@gmail.com> wrote:
Hello
How do to write a synchronized class like in java for Ruby
I try with a Mutex but if a method call another method of the same
instance I obtain a Deadlock.I wrote a reentrant mutex class at one point in time ...
Give it a shot and see if it fixes your deadlock issue.
--
remember.guy do |as, often| as.you_can - without end
http://blog.rubybestpractices.com/