PATH:
usr
/
include
/
c++
/
11
// <latch> -*- C++ -*- // Copyright (C) 2020-2021 Free Software Foundation, Inc. // // This file is part of the GNU ISO C++ Library. This library is free // software; you can redistribute it and/or modify it under the // terms of the GNU General Public License as published by the // Free Software Foundation; either version 3, or (at your option) // any later version. // This library is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // Under Section 7 of GPL version 3, you are granted additional // permissions described in the GCC Runtime Library Exception, version // 3.1, as published by the Free Software Foundation. // You should have received a copy of the GNU General Public License and // a copy of the GCC Runtime Library Exception along with this program; // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see // <http://www.gnu.org/licenses/>. /** @file include/latch * This is a Standard C++ Library header. */ #ifndef _GLIBCXX_LATCH #define _GLIBCXX_LATCH 1 #pragma GCC system_header #if __cplusplus > 201703L #include <bits/atomic_base.h> #include <ext/numeric_traits.h> #if __cpp_lib_atomic_wait namespace std _GLIBCXX_VISIBILITY(default) { _GLIBCXX_BEGIN_NAMESPACE_VERSION #define __cpp_lib_latch 201907L class latch { public: static constexpr ptrdiff_t max() noexcept { return __gnu_cxx::__int_traits<__detail::__platform_wait_t>::__max; } constexpr explicit latch(ptrdiff_t __expected) noexcept : _M_a(__expected) { } ~latch() = default; latch(const latch&) = delete; latch& operator=(const latch&) = delete; _GLIBCXX_ALWAYS_INLINE void count_down(ptrdiff_t __update = 1) { auto const __old = __atomic_impl::fetch_sub(&_M_a, __update, memory_order::release); if (__old == __update) __atomic_impl::notify_all(&_M_a); } _GLIBCXX_ALWAYS_INLINE bool try_wait() const noexcept { return __atomic_impl::load(&_M_a, memory_order::acquire) == 0; } _GLIBCXX_ALWAYS_INLINE void wait() const noexcept { auto const __pred = [this] { return this->try_wait(); }; std::__atomic_wait_address(&_M_a, __pred); } _GLIBCXX_ALWAYS_INLINE void arrive_and_wait(ptrdiff_t __update = 1) noexcept { count_down(__update); wait(); } private: alignas(__alignof__(__detail::__platform_wait_t)) __detail::__platform_wait_t _M_a; }; _GLIBCXX_END_NAMESPACE_VERSION } // namespace #endif // __cpp_lib_atomic_wait #endif // __cplusplus > 201703L #endif // _GLIBCXX_LATCH
[+]
..
[-] cuchar
[edit]
[-] clocale
[edit]
[-] variant
[edit]
[-] cfenv
[edit]
[-] numeric
[edit]
[-] random
[edit]
[-] version
[edit]
[-] deque
[edit]
[-] cwctype
[edit]
[-] ostream
[edit]
[-] valarray
[edit]
[-] mutex
[edit]
[-] bitset
[edit]
[-] cstdalign
[edit]
[-] cstdint
[edit]
[-] limits
[edit]
[-] stop_token
[edit]
[-] complex.h
[edit]
[+]
tr2
[-] ranges
[edit]
[+]
experimental
[-] string_view
[edit]
[-] coroutine
[edit]
[-] ios
[edit]
[-] cassert
[edit]
[-] iostream
[edit]
[-] istream
[edit]
[-] new
[edit]
[-] concepts
[edit]
[-] condition_variable
[edit]
[-] cwchar
[edit]
[+]
backward
[-] cstdarg
[edit]
[-] type_traits
[edit]
[-] functional
[edit]
[-] climits
[edit]
[-] stdexcept
[edit]
[+]
bits
[-] memory
[edit]
[-] cstdlib
[edit]
[-] list
[edit]
[+]
tr1
[-] map
[edit]
[-] tgmath.h
[edit]
[-] filesystem
[edit]
[-] fenv.h
[edit]
[-] cmath
[edit]
[-] queue
[edit]
[-] ccomplex
[edit]
[-] csetjmp
[edit]
[-] shared_mutex
[edit]
[-] span
[edit]
[-] cstdio
[edit]
[-] barrier
[edit]
[-] ratio
[edit]
[-] memory_resource
[edit]
[-] csignal
[edit]
[-] optional
[edit]
[-] cstdbool
[edit]
[-] set
[edit]
[-] ctgmath
[edit]
[-] latch
[edit]
[-] unordered_set
[edit]
[-] fstream
[edit]
[-] cerrno
[edit]
[-] execution
[edit]
[-] ctime
[edit]
[-] stack
[edit]
[-] string
[edit]
[-] syncstream
[edit]
[-] bit
[edit]
[-] tuple
[edit]
[-] streambuf
[edit]
[-] scoped_allocator
[edit]
[-] chrono
[edit]
[-] numbers
[edit]
[-] algorithm
[edit]
[-] cstddef
[edit]
[-] vector
[edit]
[-] future
[edit]
[-] math.h
[edit]
[-] atomic
[edit]
[+]
ext
[-] utility
[edit]
[+]
parallel
[-] unordered_map
[edit]
[-] cxxabi.h
[edit]
[-] forward_list
[edit]
[+]
decimal
[-] array
[edit]
[-] codecvt
[edit]
[-] typeindex
[edit]
[-] ciso646
[edit]
[-] cfloat
[edit]
[+]
debug
[-] iterator
[edit]
[-] initializer_list
[edit]
[-] cinttypes
[edit]
[+]
pstl
[-] exception
[edit]
[-] cctype
[edit]
[-] iomanip
[edit]
[-] sstream
[edit]
[-] stdlib.h
[edit]
[-] typeinfo
[edit]
[-] source_location
[edit]
[+]
x86_64-redhat-linux
[-] cstring
[edit]
[-] charconv
[edit]
[-] regex
[edit]
[-] iosfwd
[edit]
[-] system_error
[edit]
[-] complex
[edit]
[-] semaphore
[edit]
[-] locale
[edit]
[-] compare
[edit]
[-] any
[edit]
[-] thread
[edit]