Subj : Re: Challenge: Multithreading & Synchronization To : comp.programming.threads From : Uenal Mutlu Date : Wed May 18 2005 09:29 pm "Sergei Organov" wrote > "Uenal Mutlu" writes: > > "Sergei Organov" wrote > > > "Uenal Mutlu" writes: > [...] > > > I'm afraid it's so broken that it can't be fixed in parts. > > > > What exactly do you mean is broken? > > Almost everything. > > > > If you indeed need something working immediately, create single > > > recursive lock and lock/unlock it at entry/exit to every function, > > > deliver the application, and then start to re-design your > > > application ASAP, where ASAP in fact means "as soon as you actually > > > understand where and why it is flawed." > > > > Can you give an example for just the member function f2(), or more if > > possible? > > Sorry, f2() with lock() at the beginning and unlock() at the end? Or > f2() in a supposed to be a good design? In the former case it's trivial, in > the latter case I'm afraid there will be no f2(). lock(), unlock() applied to what? Why would you remove f2() since it is a member function, ie. an API function. I wonder how else you would design the class. > > > > What's unclear to you? The aim is to collect multiple solutions to the > > > > problem. > > > > > > You see, for me your challenge sounds like this: "For undisclosed > > > purpose I've created this messy broken skeleton and called it > > > "real-world synchronization challenge". How do you fix my problem?". > > > For me it's unclear what "solutions" you are going to collect then. > > > IMHO, the best solution is to throw it away, sorry. > > > > I don't feel so. I would say it is a well-designed classic real-world example > > for shared access to a class from multiple threads. > > Sorry, I give up. At least in C++ you don't have classes in the running > program, so they can't be accessed even from single thread. What? There is a global instance of Server called gServer... > > How would you have designed or formulated it? > > Sorry, what "it"? Of course the problem description. .