Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
// -*- C++ -*-
|
2024-05-27 09:12:27 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
//
|
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef _LIBCPP_MUTEX
|
|
|
|
#define _LIBCPP_MUTEX
|
|
|
|
|
|
|
|
/*
|
|
|
|
mutex synopsis
|
|
|
|
|
|
|
|
namespace std
|
|
|
|
{
|
|
|
|
|
|
|
|
class mutex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
constexpr mutex() noexcept;
|
|
|
|
~mutex();
|
|
|
|
|
|
|
|
mutex(const mutex&) = delete;
|
|
|
|
mutex& operator=(const mutex&) = delete;
|
|
|
|
|
|
|
|
void lock();
|
|
|
|
bool try_lock();
|
|
|
|
void unlock();
|
|
|
|
|
|
|
|
typedef pthread_mutex_t* native_handle_type;
|
|
|
|
native_handle_type native_handle();
|
|
|
|
};
|
|
|
|
|
|
|
|
class recursive_mutex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
recursive_mutex();
|
|
|
|
~recursive_mutex();
|
|
|
|
|
|
|
|
recursive_mutex(const recursive_mutex&) = delete;
|
|
|
|
recursive_mutex& operator=(const recursive_mutex&) = delete;
|
|
|
|
|
|
|
|
void lock();
|
|
|
|
bool try_lock() noexcept;
|
|
|
|
void unlock();
|
|
|
|
|
|
|
|
typedef pthread_mutex_t* native_handle_type;
|
|
|
|
native_handle_type native_handle();
|
|
|
|
};
|
|
|
|
|
|
|
|
class timed_mutex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
timed_mutex();
|
|
|
|
~timed_mutex();
|
|
|
|
|
|
|
|
timed_mutex(const timed_mutex&) = delete;
|
|
|
|
timed_mutex& operator=(const timed_mutex&) = delete;
|
|
|
|
|
|
|
|
void lock();
|
|
|
|
bool try_lock();
|
|
|
|
template <class Rep, class Period>
|
|
|
|
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
|
|
|
template <class Clock, class Duration>
|
|
|
|
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
|
|
|
void unlock();
|
|
|
|
};
|
|
|
|
|
|
|
|
class recursive_timed_mutex
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
recursive_timed_mutex();
|
|
|
|
~recursive_timed_mutex();
|
|
|
|
|
|
|
|
recursive_timed_mutex(const recursive_timed_mutex&) = delete;
|
|
|
|
recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
|
|
|
|
|
|
|
|
void lock();
|
|
|
|
bool try_lock() noexcept;
|
|
|
|
template <class Rep, class Period>
|
|
|
|
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
|
|
|
template <class Clock, class Duration>
|
|
|
|
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
|
|
|
void unlock();
|
|
|
|
};
|
|
|
|
|
|
|
|
struct defer_lock_t { explicit defer_lock_t() = default; };
|
|
|
|
struct try_to_lock_t { explicit try_to_lock_t() = default; };
|
|
|
|
struct adopt_lock_t { explicit adopt_lock_t() = default; };
|
|
|
|
|
|
|
|
inline constexpr defer_lock_t defer_lock{};
|
|
|
|
inline constexpr try_to_lock_t try_to_lock{};
|
|
|
|
inline constexpr adopt_lock_t adopt_lock{};
|
|
|
|
|
|
|
|
template <class Mutex>
|
|
|
|
class lock_guard
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Mutex mutex_type;
|
|
|
|
|
|
|
|
explicit lock_guard(mutex_type& m);
|
|
|
|
lock_guard(mutex_type& m, adopt_lock_t);
|
|
|
|
~lock_guard();
|
|
|
|
|
|
|
|
lock_guard(lock_guard const&) = delete;
|
|
|
|
lock_guard& operator=(lock_guard const&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class... MutexTypes>
|
|
|
|
class scoped_lock // C++17
|
|
|
|
{
|
|
|
|
public:
|
2024-05-27 09:12:27 +00:00
|
|
|
using mutex_type = Mutex; // Only if sizeof...(MutexTypes) == 1
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
explicit scoped_lock(MutexTypes&... m);
|
|
|
|
scoped_lock(adopt_lock_t, MutexTypes&... m);
|
|
|
|
~scoped_lock();
|
|
|
|
scoped_lock(scoped_lock const&) = delete;
|
|
|
|
scoped_lock& operator=(scoped_lock const&) = delete;
|
|
|
|
private:
|
|
|
|
tuple<MutexTypes&...> pm; // exposition only
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Mutex>
|
|
|
|
class unique_lock
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
typedef Mutex mutex_type;
|
|
|
|
unique_lock() noexcept;
|
|
|
|
explicit unique_lock(mutex_type& m);
|
|
|
|
unique_lock(mutex_type& m, defer_lock_t) noexcept;
|
|
|
|
unique_lock(mutex_type& m, try_to_lock_t);
|
|
|
|
unique_lock(mutex_type& m, adopt_lock_t);
|
|
|
|
template <class Clock, class Duration>
|
|
|
|
unique_lock(mutex_type& m, const chrono::time_point<Clock, Duration>& abs_time);
|
|
|
|
template <class Rep, class Period>
|
|
|
|
unique_lock(mutex_type& m, const chrono::duration<Rep, Period>& rel_time);
|
|
|
|
~unique_lock();
|
|
|
|
|
|
|
|
unique_lock(unique_lock const&) = delete;
|
|
|
|
unique_lock& operator=(unique_lock const&) = delete;
|
|
|
|
|
|
|
|
unique_lock(unique_lock&& u) noexcept;
|
|
|
|
unique_lock& operator=(unique_lock&& u) noexcept;
|
|
|
|
|
|
|
|
void lock();
|
|
|
|
bool try_lock();
|
|
|
|
|
|
|
|
template <class Rep, class Period>
|
|
|
|
bool try_lock_for(const chrono::duration<Rep, Period>& rel_time);
|
|
|
|
template <class Clock, class Duration>
|
|
|
|
bool try_lock_until(const chrono::time_point<Clock, Duration>& abs_time);
|
|
|
|
|
|
|
|
void unlock();
|
|
|
|
|
|
|
|
void swap(unique_lock& u) noexcept;
|
|
|
|
mutex_type* release() noexcept;
|
|
|
|
|
|
|
|
bool owns_lock() const noexcept;
|
|
|
|
explicit operator bool () const noexcept;
|
|
|
|
mutex_type* mutex() const noexcept;
|
|
|
|
};
|
|
|
|
|
|
|
|
template <class Mutex>
|
|
|
|
void swap(unique_lock<Mutex>& x, unique_lock<Mutex>& y) noexcept;
|
|
|
|
|
|
|
|
template <class L1, class L2, class... L3>
|
|
|
|
int try_lock(L1&, L2&, L3&...);
|
|
|
|
template <class L1, class L2, class... L3>
|
|
|
|
void lock(L1&, L2&, L3&...);
|
|
|
|
|
|
|
|
struct once_flag
|
|
|
|
{
|
|
|
|
constexpr once_flag() noexcept;
|
|
|
|
|
|
|
|
once_flag(const once_flag&) = delete;
|
|
|
|
once_flag& operator=(const once_flag&) = delete;
|
|
|
|
};
|
|
|
|
|
|
|
|
template<class Callable, class ...Args>
|
|
|
|
void call_once(once_flag& flag, Callable&& func, Args&&... args);
|
|
|
|
|
|
|
|
} // std
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2024-05-27 09:12:27 +00:00
|
|
|
#include <__chrono/steady_clock.h>
|
|
|
|
#include <__chrono/time_point.h>
|
|
|
|
#include <__condition_variable/condition_variable.h>
|
|
|
|
#include <__config>
|
|
|
|
#include <__memory/shared_ptr.h>
|
|
|
|
#include <__mutex/lock_guard.h>
|
|
|
|
#include <__mutex/mutex.h>
|
2024-07-23 10:16:17 +00:00
|
|
|
#include <__mutex/once_flag.h>
|
2024-05-27 09:12:27 +00:00
|
|
|
#include <__mutex/tag_types.h>
|
|
|
|
#include <__mutex/unique_lock.h>
|
2024-07-23 10:16:17 +00:00
|
|
|
#include <__thread/id.h>
|
|
|
|
#include <__thread/support.h>
|
2024-05-27 09:12:27 +00:00
|
|
|
#include <__utility/forward.h>
|
2024-07-23 10:16:17 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <limits>
|
2024-05-27 09:12:27 +00:00
|
|
|
#ifndef _LIBCPP_CXX03_LANG
|
2024-07-23 10:16:17 +00:00
|
|
|
# include <tuple>
|
2024-05-27 09:12:27 +00:00
|
|
|
#endif
|
|
|
|
#include <version>
|
|
|
|
|
|
|
|
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
|
|
|
|
# pragma GCC system_header
|
|
|
|
#endif
|
|
|
|
|
|
|
|
_LIBCPP_PUSH_MACROS
|
|
|
|
#include <__undef_macros>
|
|
|
|
|
|
|
|
_LIBCPP_BEGIN_NAMESPACE_STD
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
#ifndef _LIBCPP_HAS_NO_THREADS
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI recursive_mutex {
|
|
|
|
__libcpp_recursive_mutex_t __m_;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
recursive_mutex();
|
|
|
|
~recursive_mutex();
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
recursive_mutex(const recursive_mutex&) = delete;
|
|
|
|
recursive_mutex& operator=(const recursive_mutex&) = delete;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
void lock();
|
|
|
|
bool try_lock() _NOEXCEPT;
|
|
|
|
void unlock() _NOEXCEPT;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
typedef __libcpp_recursive_mutex_t* native_handle_type;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
_LIBCPP_HIDE_FROM_ABI native_handle_type native_handle() { return &__m_; }
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
};
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI timed_mutex {
|
|
|
|
mutex __m_;
|
|
|
|
condition_variable __cv_;
|
|
|
|
bool __locked_;
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
timed_mutex();
|
|
|
|
~timed_mutex();
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
timed_mutex(const timed_mutex&) = delete;
|
|
|
|
timed_mutex& operator=(const timed_mutex&) = delete;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
void lock();
|
|
|
|
bool try_lock() _NOEXCEPT;
|
|
|
|
template <class _Rep, class _Period>
|
|
|
|
_LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
|
|
|
|
return try_lock_until(chrono::steady_clock::now() + __d);
|
|
|
|
}
|
|
|
|
template <class _Clock, class _Duration>
|
|
|
|
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
|
|
|
|
try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
|
|
|
|
void unlock() _NOEXCEPT;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Clock, class _Duration>
|
2024-07-23 10:16:17 +00:00
|
|
|
bool timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
|
|
|
|
using namespace chrono;
|
|
|
|
unique_lock<mutex> __lk(__m_);
|
|
|
|
bool __no_timeout = _Clock::now() < __t;
|
|
|
|
while (__no_timeout && __locked_)
|
|
|
|
__no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
|
|
|
|
if (!__locked_) {
|
|
|
|
__locked_ = true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
class _LIBCPP_EXPORTED_FROM_ABI recursive_timed_mutex {
|
|
|
|
mutex __m_;
|
|
|
|
condition_variable __cv_;
|
|
|
|
size_t __count_;
|
|
|
|
__thread_id __id_;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
public:
|
|
|
|
recursive_timed_mutex();
|
|
|
|
~recursive_timed_mutex();
|
|
|
|
|
|
|
|
recursive_timed_mutex(const recursive_timed_mutex&) = delete;
|
|
|
|
recursive_timed_mutex& operator=(const recursive_timed_mutex&) = delete;
|
|
|
|
|
|
|
|
void lock();
|
|
|
|
bool try_lock() _NOEXCEPT;
|
|
|
|
template <class _Rep, class _Period>
|
|
|
|
_LIBCPP_HIDE_FROM_ABI bool try_lock_for(const chrono::duration<_Rep, _Period>& __d) {
|
|
|
|
return try_lock_until(chrono::steady_clock::now() + __d);
|
|
|
|
}
|
|
|
|
template <class _Clock, class _Duration>
|
|
|
|
_LIBCPP_METHOD_TEMPLATE_IMPLICIT_INSTANTIATION_VIS bool
|
|
|
|
try_lock_until(const chrono::time_point<_Clock, _Duration>& __t);
|
|
|
|
void unlock() _NOEXCEPT;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Clock, class _Duration>
|
2024-07-23 10:16:17 +00:00
|
|
|
bool recursive_timed_mutex::try_lock_until(const chrono::time_point<_Clock, _Duration>& __t) {
|
|
|
|
using namespace chrono;
|
|
|
|
__thread_id __id = this_thread::get_id();
|
|
|
|
unique_lock<mutex> __lk(__m_);
|
|
|
|
if (__id == __id_) {
|
|
|
|
if (__count_ == numeric_limits<size_t>::max())
|
|
|
|
return false;
|
|
|
|
++__count_;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
bool __no_timeout = _Clock::now() < __t;
|
|
|
|
while (__no_timeout && __count_ != 0)
|
|
|
|
__no_timeout = __cv_.wait_until(__lk, __t) == cv_status::no_timeout;
|
|
|
|
if (__count_ == 0) {
|
|
|
|
__count_ = 1;
|
|
|
|
__id_ = __id;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template <class _L0, class _L1>
|
2024-07-23 10:16:17 +00:00
|
|
|
_LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1) {
|
|
|
|
unique_lock<_L0> __u0(__l0, try_to_lock_t());
|
|
|
|
if (__u0.owns_lock()) {
|
|
|
|
if (__l1.try_lock()) {
|
|
|
|
__u0.release();
|
|
|
|
return -1;
|
|
|
|
} else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
# ifndef _LIBCPP_CXX03_LANG
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
template <class _L0, class _L1, class _L2, class... _L3>
|
2024-07-23 10:16:17 +00:00
|
|
|
_LIBCPP_HIDE_FROM_ABI int try_lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
|
|
|
|
int __r = 0;
|
|
|
|
unique_lock<_L0> __u0(__l0, try_to_lock);
|
|
|
|
if (__u0.owns_lock()) {
|
|
|
|
__r = std::try_lock(__l1, __l2, __l3...);
|
|
|
|
if (__r == -1)
|
|
|
|
__u0.release();
|
|
|
|
else
|
|
|
|
++__r;
|
|
|
|
}
|
|
|
|
return __r;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
# endif // _LIBCPP_CXX03_LANG
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
template <class _L0, class _L1>
|
2024-07-23 10:16:17 +00:00
|
|
|
_LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1) {
|
|
|
|
while (true) {
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
{
|
2024-07-23 10:16:17 +00:00
|
|
|
unique_lock<_L0> __u0(__l0);
|
|
|
|
if (__l1.try_lock()) {
|
|
|
|
__u0.release();
|
|
|
|
break;
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
2024-07-23 10:16:17 +00:00
|
|
|
__libcpp_thread_yield();
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
{
|
2024-07-23 10:16:17 +00:00
|
|
|
unique_lock<_L1> __u1(__l1);
|
|
|
|
if (__l0.try_lock()) {
|
|
|
|
__u1.release();
|
|
|
|
break;
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
2024-07-23 10:16:17 +00:00
|
|
|
__libcpp_thread_yield();
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
# ifndef _LIBCPP_CXX03_LANG
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
template <class _L0, class _L1, class _L2, class... _L3>
|
|
|
|
void __lock_first(int __i, _L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
|
|
|
|
while (true) {
|
|
|
|
switch (__i) {
|
|
|
|
case 0: {
|
|
|
|
unique_lock<_L0> __u0(__l0);
|
|
|
|
__i = std::try_lock(__l1, __l2, __l3...);
|
|
|
|
if (__i == -1) {
|
|
|
|
__u0.release();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++__i;
|
|
|
|
__libcpp_thread_yield();
|
|
|
|
break;
|
|
|
|
case 1: {
|
|
|
|
unique_lock<_L1> __u1(__l1);
|
|
|
|
__i = std::try_lock(__l2, __l3..., __l0);
|
|
|
|
if (__i == -1) {
|
|
|
|
__u1.release();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (__i == sizeof...(_L3) + 1)
|
|
|
|
__i = 0;
|
|
|
|
else
|
|
|
|
__i += 2;
|
|
|
|
__libcpp_thread_yield();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
std::__lock_first(__i - 2, __l2, __l3..., __l0, __l1);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
template <class _L0, class _L1, class _L2, class... _L3>
|
|
|
|
inline _LIBCPP_HIDE_FROM_ABI void lock(_L0& __l0, _L1& __l1, _L2& __l2, _L3&... __l3) {
|
|
|
|
std::__lock_first(0, __l0, __l1, __l2, __l3...);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
}
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
# endif // _LIBCPP_CXX03_LANG
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
# if _LIBCPP_STD_VER >= 17
|
|
|
|
template <class... _Mutexes>
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
class _LIBCPP_TEMPLATE_VIS scoped_lock;
|
|
|
|
|
|
|
|
template <>
|
|
|
|
class _LIBCPP_TEMPLATE_VIS scoped_lock<> {
|
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock() {}
|
|
|
|
~scoped_lock() = default;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t) {}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
scoped_lock(scoped_lock const&) = delete;
|
|
|
|
scoped_lock& operator=(scoped_lock const&) = delete;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
template <class _Mutex>
|
|
|
|
class _LIBCPP_TEMPLATE_VIS _LIBCPP_THREAD_SAFETY_ANNOTATION(scoped_lockable) scoped_lock<_Mutex> {
|
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
typedef _Mutex mutex_type;
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
private:
|
2024-07-23 10:16:17 +00:00
|
|
|
mutex_type& __m_;
|
|
|
|
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
[[nodiscard]]
|
|
|
|
_LIBCPP_HIDE_FROM_ABI explicit scoped_lock(mutex_type& __m) _LIBCPP_THREAD_SAFETY_ANNOTATION(acquire_capability(__m))
|
|
|
|
: __m_(__m) {
|
|
|
|
__m_.lock();
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
~scoped_lock() _LIBCPP_THREAD_SAFETY_ANNOTATION(release_capability()) { __m_.unlock(); }
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(adopt_lock_t, mutex_type& __m)
|
|
|
|
_LIBCPP_THREAD_SAFETY_ANNOTATION(requires_capability(__m))
|
|
|
|
: __m_(__m) {}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
scoped_lock(scoped_lock const&) = delete;
|
|
|
|
scoped_lock& operator=(scoped_lock const&) = delete;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
};
|
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
template <class... _MArgs>
|
|
|
|
class _LIBCPP_TEMPLATE_VIS scoped_lock {
|
|
|
|
static_assert(sizeof...(_MArgs) > 1, "At least 2 lock types required");
|
|
|
|
typedef tuple<_MArgs&...> _MutexTuple;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
public:
|
2024-07-23 10:16:17 +00:00
|
|
|
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI explicit scoped_lock(_MArgs&... __margs) : __t_(__margs...) {
|
|
|
|
std::lock(__margs...);
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI scoped_lock(adopt_lock_t, _MArgs&... __margs) : __t_(__margs...) {}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
_LIBCPP_HIDE_FROM_ABI ~scoped_lock() {
|
|
|
|
typedef typename __make_tuple_indices<sizeof...(_MArgs)>::type _Indices;
|
|
|
|
__unlock_unpack(_Indices{}, __t_);
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
scoped_lock(scoped_lock const&) = delete;
|
|
|
|
scoped_lock& operator=(scoped_lock const&) = delete;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
private:
|
2024-07-23 10:16:17 +00:00
|
|
|
template <size_t... _Indx>
|
|
|
|
_LIBCPP_HIDE_FROM_ABI static void __unlock_unpack(__tuple_indices<_Indx...>, _MutexTuple& __mt) {
|
|
|
|
(std::get<_Indx>(__mt).unlock(), ...);
|
|
|
|
}
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
_MutexTuple __t_;
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
};
|
2024-05-27 09:12:27 +00:00
|
|
|
_LIBCPP_CTAD_SUPPORTED_FOR_TYPE(scoped_lock);
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
2024-07-23 10:16:17 +00:00
|
|
|
# endif // _LIBCPP_STD_VER >= 17
|
|
|
|
#endif // !_LIBCPP_HAS_NO_THREADS
|
Import C++ Standard Template Library
You can now use the hardest fastest and most dangerous language there is
with Cosmopolitan. So far about 75% of LLVM libcxx has been added. A few
breaking changes needed to be made to help this go smoothly.
- Rename nothrow to dontthrow
- Rename nodiscard to dontdiscard
- Add some libm functions, e.g. lgamma, nan, etc.
- Change intmax_t from int128 to int64 like everything else
- Introduce %jjd formatting directive for int128_t
- Introduce strtoi128(), strtou128(), etc.
- Rename bsrmax() to bsr128()
Some of the templates that should be working currently are std::vector,
std::string, std::map, std::set, std::deque, etc.
2022-03-22 12:51:41 +00:00
|
|
|
|
|
|
|
_LIBCPP_END_NAMESPACE_STD
|
|
|
|
|
|
|
|
_LIBCPP_POP_MACROS
|
|
|
|
|
2024-05-27 09:12:27 +00:00
|
|
|
#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
|
|
|
|
# include <atomic>
|
|
|
|
# include <concepts>
|
|
|
|
# include <cstdlib>
|
|
|
|
# include <cstring>
|
|
|
|
# include <ctime>
|
|
|
|
# include <initializer_list>
|
2024-07-23 10:16:17 +00:00
|
|
|
# include <iosfwd>
|
2024-05-27 09:12:27 +00:00
|
|
|
# include <new>
|
|
|
|
# include <stdexcept>
|
|
|
|
# include <system_error>
|
|
|
|
# include <type_traits>
|
|
|
|
# include <typeinfo>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif // _LIBCPP_MUTEX
|