Return-Path: Delivered-To: apmail-incubator-stdcxx-dev-archive@www.apache.org Received: (qmail 32866 invoked from network); 17 Sep 2007 20:28:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 17 Sep 2007 20:28:03 -0000 Received: (qmail 91140 invoked by uid 500); 17 Sep 2007 20:27:55 -0000 Delivered-To: apmail-incubator-stdcxx-dev-archive@incubator.apache.org Received: (qmail 91127 invoked by uid 500); 17 Sep 2007 20:27:55 -0000 Mailing-List: contact stdcxx-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: stdcxx-dev@incubator.apache.org Delivered-To: mailing list stdcxx-dev@incubator.apache.org Received: (qmail 91115 invoked by uid 99); 17 Sep 2007 20:27:55 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 13:27:55 -0700 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [208.30.140.160] (HELO moroha.quovadx.com) (208.30.140.160) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 17 Sep 2007 20:27:54 +0000 Received: from qxvcexch01.ad.quovadx.com ([192.168.170.59]) by moroha.quovadx.com (8.13.6/8.13.6) with ESMTP id l8HKRVs4031229 for ; Mon, 17 Sep 2007 20:27:31 GMT Received: from [10.70.3.113] ([10.70.3.113]) by qxvcexch01.ad.quovadx.com with Microsoft SMTPSVC(6.0.3790.1830); Mon, 17 Sep 2007 14:26:32 -0600 Message-ID: <46EEE333.4020700@roguewave.com> Date: Mon, 17 Sep 2007 14:27:31 -0600 From: Martin Sebor Organization: Rogue Wave Software, Inc. User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.6) Gecko/20070802 SeaMonkey/1.1.4 MIME-Version: 1.0 To: stdcxx-dev@incubator.apache.org Subject: Re: [PATCH] std::messages thread safety References: <7BDB2168BEAEF14C98F1901FD2DE6438F57A7C@epmsa009.minsk.epam.com> <46EACCF5.7010402@roguewave.com> <46EC2DB9.5080302@roguewave.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 17 Sep 2007 20:26:32.0353 (UTC) FILETIME=[09232910:01C7F969] X-Virus-Checked: Checked by ClamAV on apache.org Travis Vitek wrote: > Martin Sebor wrote: >> Travis Vitek wrote: >>> Martin Sebor wrote: >>> >>>> AFAIK, catopen() and catgets() are not required to be thread >>>> safe so we need to guard calls to them across all instances of >>>> the facet. >>>> >>> Yes, but the affected functions are doing more than just calling >>> catgets() and catopen(). Since they are using shared data, they >>> need to lock that shared data with a shared mutex. >> And unless I'm missing something, they are. >> >> _RWSTD_MT_STATIC_GUARD (__rw_open_cat_data); >> >> This provides mutual exclusion across all othe such guards >> (i.e, those with the same type as an argument). >> > > Nope. See _defs.h... Ouch! You're right. My bad for misremembering, and for misnaming the macros in the first place. I withdraw my objection to the patch :) Martin > > // synchronizes access by all objects holding the same mutex > # define _RWSTD_MT_GUARD(mutex) \ > _RW::__rw_guard _RWSTD_PASTE (__guard, __LINE__) (mutex) > > // synchronizes access by all threads holding the same mutex > # define _RWSTD_MT_STATIC_GUARD(type) \ > typedef _RW::__rw_type _UniqueType; \ > _RWSTD_MT_CLASS_GUARD(_UniqueType) > > // synchronizes access by all objects of the same type > # define _RWSTD_MT_CLASS_GUARD(type) \ > _RWSTD_MT_GUARD (_RW::__rw_get_static_mutex ((type*)0)) > > _RWSTD_MT_CLASS_GUARD locks a static mutex that unique for the type > provided. This provides the behavior that you are describing above. > > _RWSTD_MT_STATIC_GUARD creates a unique type given a type and a line > number. That new type is then used to get a handle to a static mutex. > The only time two _RWSTD_MT_STATIC_GUARD lines are guarding the same > mutex is if they happen to be on the same line number and have the > same type argument. > > Travis