From: Robert Klemme Date: 2005-10-13T23:26:54+09:00 Subject: Re: How to overload Object's methods automagicaly? S.Z. wrote: > Robert Klemme wrote: >> I did already. Every scenario where at least two method calls on >> the same or multiple objects have to be atomic with regard to other >> threads' activities. > Below you have mentioned Monitor#synchronized(), that is just a > contradiction. Where is this a contradiction? >> You have that feature already with Mutex#synchronized and >> Monitor#synchronized. There's also a variant as mixin (see doc ref >> below). > Yes I have. But I dislike both. I know a better solution only for > scenarios where my Sync class can be applied. But I am looking for the > others... What's your problem with these? Why do you dislike them? Why can't you use them to implement your Sync class? >> So you're using Java's delegation approach > Yes, I do the same with Ruby. > >> You don't need to create that on your own. It's already there > Look at MonitorMixin example: > http://www.ruby-doc.org/stdlib/libdoc/monitor/rdoc/classes/MonitorMixin.html > Is not this an errorprone code? I need a better sync mechanism that > defines "producer" and "consumer" and has the correct zyncronization > built in. If you're in a producer consumer scenario use a Queue. http://www.ruby-doc.org/stdlib/libdoc/thread/rdoc/classes/Queue.html Seriously, I really don't know why you think you have to cook something completely new while there is lots of stuff that seems to be doing what you need. Maybe it's just a language issue but I have the feeling that you always write at most half of what you think. That makes it really hard to follow this thread. Cheers robert