On Oct 1, 2012, at 2:38 AM, "shugo (Shugo Maeda)" <redmine / ruby-lang.org> wr= ote: >=20 > Issue #7087 has been updated by shugo (Shugo Maeda). >=20 >=20 > kosaki (Motohiro KOSAKI) wrote: >> monitor is based on Java monitor semantics. >=20 > My Java knowledge is rusted, but monitor is not based on Java monitor sema= ntics, at least when it was designed. Java's monitor mechanism mixes a mute= x and a condition variable into one object, but I don't think it's well desi= gned. I guess Java has a better solution (java.util.concurrent.locks.{Lock,= Condition}?) now. The name monitor was taken from Java, but it was just bec= ause the name mutex had been already taken at that time. >=20 > rklemme (Robert Klemme) wrote: >> kosaki (Motohiro KOSAKI) wrote: >>> At least, this is intentional. condtion variable and monitor have differ= ent inspiration source. >>> condition variable is based on POSIX CV and monitor is based on Java mon= itor semantics. To be >>> honest, I'm not familiar Java's conditon variable. >>=20 >> For me the difference between Mutex and Monitor is only reentrancy. Othe= r than that I'd have expected them to be identical (usage and interface). >=20 > Monitor has its own version of ConditionVariable. Use Monitor#new_cond to= get its instance. >=20 >>> Could you please explain the detail of your >>> suggestion? Which semantics do you hope? >>=20 >> I would have expected that I can use a Monitor / instance which includes M= onitorMixin the same way as a Mutex with ::ConditionVariable. If that is no= t intended then I'd rather have an exception TypeError from ::ConditionVaria= ble#wait indicating that a Mutex must be used than the exception about the p= rivate sleep method (which happens to be the one from Kernel). >=20 > It's not intended, but TypeError is not preferred in Ruby because it break= s duck typing. > I think it's better to add Mutex#new_cond and to make the argument of Cond= itionVariable#wait obsolete. > Java's java.util.concurrent.locks.Lock seems to have an equivalent method c= alled newCondition(). >=20 > ---------------------------------------- > Bug #7087: ::ConditionVariable#wait does not work with Monitor because Mon= itor#sleep does not exist > https://bugs.ruby-lang.org/issues/7087#change-29819 >=20 > Author: rklemme (Robert Klemme) > Status: Open > Priority: Low > Assignee:=20 > Category:=20 > Target version:=20 > ruby -v: ruby 1.9.3p194 (2012-04-20) [i686-linux] >=20 >=20 > See program attached to bug #7086: timeout_4 always throws: >=20 > ERROR: method "timeout_4": #<NoMethodError: private method `sleep' called f= or #<Monitor:0x87e49f8>> >=20 > $ irb19 -r monitor > irb(main):001:0> Monitor.new.method(:sleep) > =3D> #<Method: Monitor(Kernel)#sleep> > irb(main):002:0> Monitor.instance_methods.grep /sleep/ > =3D> [] >=20 >=20 > --=20 > http://bugs.ruby-lang.org/ >=20