Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Synchronizing different classes on the same mutex in C++

3 views
Skip to first unread message

Francesco Balestrieri

unread,
Aug 28, 2002, 6:46:35 AM8/28/02
to
Hi,

I have a number of C++ classes, and I would like all their instances to
synchronize on the same mutex. The reason is that the classes contain linked
lists to objects of the other classes, and need to navigate several objects'
data.

So far I came up with these possibilities:

- have an interface class that accesses the objects in mutual exclusion, and
have all navigations done via this class. Problem: I have to rewrite a lot
of additional methods.
- have a global mutex and pass it to the objects in the constructor.
Problem: it's not transparent to the user.

I have the feeling that there is a better, more OO way to do it, but can't
figure it out myself. Can anybody suggest something, or at least give a
reference I could check? I guess you can tell from the way I put the
question that I'm new to this sort of things, so I apologise already if this
is a dumb question.

Thanks in advance,

Francesco


Alexander Terekhov

unread,
Aug 28, 2002, 8:39:18 AM8/28/02
to

Well (please note this *ISN'T* recommendation), you might
want to take a look at the following ``informit'' article:

http://www.informit.com/isapi/product_id~{E3967A89-4E20-425B-BCFF-B84B6DEED6CA}/element_id~{FA20557C-0C4D-4374-88DF-45AF30D9E407}/st~3FAD3499-20A6-4782-9A96-05825F8E6E5B/session_id~{28113876-E578-4305-AB03-D377C54CDEB7}/content/articlex.asp
(Multithreading and the C++ Type System, FEB 08, 2002 By Andrei Alexandrescu. Article is provided courtesy of Addison Wesley. )

Well (to put things in historical perspective), you might
also want to click here (or perhaps copy&paste this ;-) ):

http://groups.google.com/groups?selm=3D662CEB.BD172CCA%40web.de
(Subject: Re: stl deques and "volatile")

regards,
alexander.

P.S. http://groups.google.com/groups?threadm=3D52CD8A.1070009%40tellabs.com
(Subject: Re: Thread-Safe Classes)

0 new messages