From patchwork Fri May 13 12:40:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonathan Wakely X-Patchwork-Id: 53939 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E253F395BC78 for ; Fri, 13 May 2022 13:00:31 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E253F395BC78 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1652446831; bh=nwphmdkWZEh5u9ux2HwI4l1028U9GYqVpBnwnHzImls=; h=To:Subject:Date:In-Reply-To:References:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=F9dMnNqOv+4BFuClb8qEKkj8dZxaebjVY3pkPsJoP6dgfGt35cdiTnI27pVfoptJR wnYpPHlbuAHc0oVYFOyQ+eOZUwHvK9AdlYMuJDFk0vB2po0QHpvl4AjHYzSy8cQ70n RuzPnsf7HlwQcc6eEN5V0/Fcfure5NFjgvyGr72E= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 99BDF395B43B for ; Fri, 13 May 2022 12:41:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99BDF395B43B Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-103-JBZL_QbPPI-lsufV6zGNuQ-1; Fri, 13 May 2022 08:41:01 -0400 X-MC-Unique: JBZL_QbPPI-lsufV6zGNuQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 57B671C05AF4; Fri, 13 May 2022 12:41:01 +0000 (UTC) Received: from localhost (unknown [10.33.36.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1DC6C2026D6A; Fri, 13 May 2022 12:41:01 +0000 (UTC) To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [committed 12/12] libstdc++: Improve doxygen docs for Date: Fri, 13 May 2022 13:40:50 +0100 Message-Id: <20220513124050.4028450-12-jwakely@redhat.com> In-Reply-To: <20220513124050.4028450-1-jwakely@redhat.com> References: <20220513124050.4028450-1-jwakely@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-13.0 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jonathan Wakely via Gcc-patches From: Jonathan Wakely Reply-To: Jonathan Wakely Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Tested powerpc64le-linux, pushed to trunk. -- >8 -- libstdc++-v3/ChangeLog: * doc/doxygen/user.cfg.in (PREDEFINED): Define _GTHREAD_USE_MUTEX_TIMEDLOCK macro. * include/bits/std_mutex.h (mutex, lock_guard): Use @since and @headerfile. * include/bits/unique_lock.h (unique_lock): Likewise. * include/std/mutex (recursive_mutex, timed_mutex) (recursive_timed_mutex, scoped_lock): Likewise. --- libstdc++-v3/doc/doxygen/user.cfg.in | 1 + libstdc++-v3/include/bits/std_mutex.h | 21 +++++++++++++- libstdc++-v3/include/bits/unique_lock.h | 2 ++ libstdc++-v3/include/std/mutex | 38 +++++++++++++++++++++++-- 4 files changed, 58 insertions(+), 4 deletions(-) diff --git a/libstdc++-v3/doc/doxygen/user.cfg.in b/libstdc++-v3/doc/doxygen/user.cfg.in index 4d21968cc57..c034b864928 100644 --- a/libstdc++-v3/doc/doxygen/user.cfg.in +++ b/libstdc++-v3/doc/doxygen/user.cfg.in @@ -2325,6 +2325,7 @@ INCLUDE_FILE_PATTERNS = PREDEFINED = __cplusplus=202002L \ __GTHREADS \ _GLIBCXX_HAS_GTHREADS \ + _GTHREAD_USE_MUTEX_TIMEDLOCK \ _GLIBCXX_HAVE_TLS \ _GLIBCXX_INCLUDE_AS_CXX11 \ "_GLIBCXX_PURE= " \ diff --git a/libstdc++-v3/include/bits/std_mutex.h b/libstdc++-v3/include/bits/std_mutex.h index d3a1d5eaec9..b22e0e12793 100644 --- a/libstdc++-v3/include/bits/std_mutex.h +++ b/libstdc++-v3/include/bits/std_mutex.h @@ -53,6 +53,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ #ifdef _GLIBCXX_HAS_GTHREADS + /// @cond undocumented + // Common base class for std::mutex and std::timed_mutex class __mutex_base { @@ -78,8 +80,19 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __mutex_base(const __mutex_base&) = delete; __mutex_base& operator=(const __mutex_base&) = delete; }; + /// @endcond - /// The standard mutex type. + /** The standard mutex type. + * + * A simple, non-recursive, non-timed mutex. + * + * Do not call `lock()` and `unlock()` directly, use a scoped lock type + * such as `std::unique_lock`, `std::lock_guard`, or (since C++17) + * `std::scoped_lock`. + * + * @headerfile mutex + * @since C++11 + */ class mutex : private __mutex_base { public: @@ -123,6 +136,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { return &_M_mutex; } }; + /// @cond undocumented + // Implementation details for std::condition_variable class __condvar { @@ -192,6 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION __gthread_cond_t _M_cond; #endif }; + /// @endcond #endif // _GLIBCXX_HAS_GTHREADS @@ -218,6 +234,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * * A lock_guard controls mutex ownership within a scope, releasing * ownership in the destructor. + * + * @headerfile mutex + * @since C++11 */ template class lock_guard diff --git a/libstdc++-v3/include/bits/unique_lock.h b/libstdc++-v3/include/bits/unique_lock.h index 1f1aa15c463..9ed7ba25766 100644 --- a/libstdc++-v3/include/bits/unique_lock.h +++ b/libstdc++-v3/include/bits/unique_lock.h @@ -51,7 +51,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * to another unique_lock by move construction or move assignment. If a * mutex lock is owned when the destructor runs ownership will be released. * + * @headerfile mutex * @ingroup mutexes + * @since C++11 */ template class unique_lock diff --git a/libstdc++-v3/include/std/mutex b/libstdc++-v3/include/std/mutex index f500818d9c9..b9590bbf276 100644 --- a/libstdc++-v3/include/std/mutex +++ b/libstdc++-v3/include/std/mutex @@ -62,6 +62,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION */ #ifdef _GLIBCXX_HAS_GTHREADS + /// @cond undocumented // Common base class for std::recursive_mutex and std::recursive_timed_mutex class __recursive_mutex_base @@ -89,8 +90,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { __gthread_recursive_mutex_destroy(&_M_mutex); } #endif }; + /// @endcond - /// The standard recursive mutex type. + /** The standard recursive mutex type. + * + * A recursive mutex can be locked more than once by the same thread. + * Other threads cannot lock the mutex until the owning thread unlocks it + * as many times as it was locked. + * + * @headerfile mutex + * @since C++11 + */ class recursive_mutex : private __recursive_mutex_base { public: @@ -132,6 +142,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION }; #if _GTHREAD_USE_MUTEX_TIMEDLOCK + /// @cond undocumented + template class __timed_mutex_impl { @@ -207,8 +219,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION return false; } }; + /// @endcond - /// The standard timed mutex type. + /** The standard timed mutex type. + * + * A non-recursive mutex that supports a timeout when trying to acquire the + * lock. + * + * @headerfile mutex + * @since C++11 + */ class timed_mutex : private __mutex_base, public __timed_mutex_impl { @@ -273,7 +293,16 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif }; - /// recursive_timed_mutex + /** The standard recursive timed mutex type. + * + * A recursive mutex that supports a timeout when trying to acquire the + * lock. A recursive mutex can be locked more than once by the same thread. + * Other threads cannot lock the mutex until the owning thread unlocks it + * as many times as it was locked. + * + * @headerfile mutex + * @since C++11 + */ class recursive_timed_mutex : private __recursive_mutex_base, public __timed_mutex_impl @@ -687,6 +716,9 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION * * A scoped_lock controls mutex ownership within a scope, releasing * ownership in the destructor. + * + * @headerfile mutex + * @since C++17 */ template class scoped_lock