Skip to content

Commit 9917484

Browse files
authored
[libc++] Make std::jthread supported in non-experimental mode (#107900)
We waited before supporting std::jthread fully because we wanted to investigate other implementation strategies (in particular one involving std::mutex). Since then, we did some benchmarking and decided that we wouldn't be moving forward with std::mutex. Hence, there is no real reason to punt on making std::jthread & friends non-experimental.
1 parent 1642f64 commit 9917484

File tree

20 files changed

+49
-58
lines changed

20 files changed

+49
-58
lines changed

libcxx/docs/ReleaseNotes/20.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ Implemented Papers
4141
- P2747R2: ``constexpr`` placement new (`Github <https://github.com/llvm/llvm-project/issues/105427>`__)
4242
- P2609R3: Relaxing Ranges Just A Smidge (`Github <https://github.com/llvm/llvm-project/issues/105253>`__)
4343
- P2985R0: A type trait for detecting virtual base classes (`Github <https://github.com/llvm/llvm-project/issues/105432>`__)
44+
- ``std::jthread`` and ``<stop_token>`` are not guarded behind ``-fexperimental-library`` anymore
4445

4546

4647
Improvements and New Features

libcxx/docs/Status/Cxx20Papers.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
"`P0553R4 <https://wg21.link/P0553R4>`__","Bit operations","2019-07 (Cologne)","|Complete|","9.0",""
106106
"`P0631R8 <https://wg21.link/P0631R8>`__","Math Constants","2019-07 (Cologne)","|Complete|","11.0",""
107107
"`P0645R10 <https://wg21.link/P0645R10>`__","Text Formatting","2019-07 (Cologne)","|Complete|","14.0","The implementation was complete since LLVM 14, but the feature-test macro was not set until LLVM 19"
108-
"`P0660R10 <https://wg21.link/P0660R10>`__","Stop Token and Joining Thread, Rev 10.","2019-07 (Cologne)","|Complete|","18.0","The paper is implemented but the features are experimental and can be enabled via ``-fexperimental-library``."
108+
"`P0660R10 <https://wg21.link/P0660R10>`__","Stop Token and Joining Thread, Rev 10.","2019-07 (Cologne)","|Complete|","20.0","The feature was implemented since LLVM 18 but was guarded behind ``-fexperimental-library``."
109109
"`P0784R7 <https://wg21.link/P0784R7>`__","More constexpr containers","2019-07 (Cologne)","|Complete|","12.0",""
110110
"`P0980R1 <https://wg21.link/P0980R1>`__","Making std::string constexpr","2019-07 (Cologne)","|Complete|","15.0",""
111111
"`P1004R2 <https://wg21.link/P1004R2>`__","Making std::vector constexpr","2019-07 (Cologne)","|Complete|","15.0",""

libcxx/docs/UserDocumentation.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,8 @@ The following features are currently considered experimental and are only provid
6969
when ``-fexperimental-library`` is passed:
7070

7171
* The parallel algorithms library (``<execution>`` and the associated algorithms)
72-
* ``std::stop_token``, ``std::stop_source`` and ``std::stop_callback``
73-
* ``std::jthread``
7472
* ``std::chrono::tzdb`` and related time zone functionality
73+
* ``<syncstream>``
7574

7675
.. note::
7776
Experimental libraries are experimental.

libcxx/include/__config

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,6 @@ _LIBCPP_HARDENING_MODE_DEBUG
224224
// easier to grep for target specific flags once the feature is complete.
225225
# if !defined(_LIBCPP_ENABLE_EXPERIMENTAL) && !defined(_LIBCPP_BUILDING_LIBRARY)
226226
# define _LIBCPP_HAS_NO_INCOMPLETE_PSTL
227-
# define _LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN
228227
# define _LIBCPP_HAS_NO_EXPERIMENTAL_TZDB
229228
# define _LIBCPP_HAS_NO_EXPERIMENTAL_SYNCSTREAM
230229
# endif

libcxx/include/__stop_token/atomic_unique_lock.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
//
88
//===----------------------------------------------------------------------===//
99

10-
#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H
11-
#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H
10+
#ifndef _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
11+
#define _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H
1212

1313
#include <__bit/popcount.h>
1414
#include <__config>
@@ -133,8 +133,8 @@ class _LIBCPP_AVAILABILITY_SYNC __atomic_unique_lock {
133133
_LIBCPP_HIDE_FROM_ABI static constexpr auto __set_locked_bit = [](_State __state) { return __state | _LockedBit; };
134134
};
135135

136-
#endif // _LIBCPP_STD_VER >= 20
136+
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
137137

138138
_LIBCPP_END_NAMESPACE_STD
139139

140-
#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_GUARD_H
140+
#endif // _LIBCPP___STOP_TOKEN_ATOMIC_UNIQUE_LOCK_H

libcxx/include/__stop_token/stop_callback.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ _LIBCPP_PUSH_MACROS
3131

3232
_LIBCPP_BEGIN_NAMESPACE_STD
3333

34-
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
34+
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
3535

3636
template <class _Callback>
3737
class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base {
@@ -93,10 +93,10 @@ class _LIBCPP_AVAILABILITY_SYNC stop_callback : private __stop_callback_base {
9393
template <class _Callback>
9494
_LIBCPP_AVAILABILITY_SYNC stop_callback(stop_token, _Callback) -> stop_callback<_Callback>;
9595

96-
#endif // _LIBCPP_STD_VER >= 20
96+
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
9797

9898
_LIBCPP_END_NAMESPACE_STD
9999

100100
_LIBCPP_POP_MACROS
101101

102-
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
102+
#endif // _LIBCPP___STOP_TOKEN_STOP_CALLBACK_H

libcxx/include/__stop_token/stop_source.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222

2323
_LIBCPP_BEGIN_NAMESPACE_STD
2424

25-
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
25+
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
2626

2727
struct nostopstate_t {
2828
explicit nostopstate_t() = default;
@@ -84,8 +84,8 @@ class _LIBCPP_AVAILABILITY_SYNC stop_source {
8484
__intrusive_shared_ptr<__stop_state> __state_;
8585
};
8686

87-
#endif // _LIBCPP_STD_VER >= 20
87+
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
8888

8989
_LIBCPP_END_NAMESPACE_STD
9090

91-
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
91+
#endif // _LIBCPP___STOP_TOKEN_STOP_SOURCE_H

libcxx/include/__stop_token/stop_token.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
_LIBCPP_BEGIN_NAMESPACE_STD
2222

23-
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
23+
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
2424

2525
class _LIBCPP_AVAILABILITY_SYNC stop_token {
2626
public:
@@ -56,7 +56,7 @@ class _LIBCPP_AVAILABILITY_SYNC stop_token {
5656
_LIBCPP_HIDE_FROM_ABI explicit stop_token(const __intrusive_shared_ptr<__stop_state>& __state) : __state_(__state) {}
5757
};
5858

59-
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN) && !defined(_LIBCPP_HAS_NO_THREADS)
59+
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_THREADS)
6060

6161
_LIBCPP_END_NAMESPACE_STD
6262

libcxx/include/__thread/jthread.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
_LIBCPP_PUSH_MACROS
3131
#include <__undef_macros>
3232

33-
#if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)
33+
#if _LIBCPP_STD_VER >= 20
3434

3535
_LIBCPP_BEGIN_NAMESPACE_STD
3636

@@ -127,7 +127,7 @@ class _LIBCPP_AVAILABILITY_SYNC jthread {
127127

128128
_LIBCPP_END_NAMESPACE_STD
129129

130-
#endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)
130+
#endif // _LIBCPP_STD_VER >= 20
131131

132132
_LIBCPP_POP_MACROS
133133

libcxx/include/condition_variable

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public:
173173
template <class _Lock, class _Rep, class _Period, class _Predicate>
174174
bool _LIBCPP_HIDE_FROM_ABI wait_for(_Lock& __lock, const chrono::duration<_Rep, _Period>& __d, _Predicate __pred);
175175

176-
# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)
176+
# if _LIBCPP_STD_VER >= 20
177177

178178
template <class _Lock, class _Predicate>
179179
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool wait(_Lock& __lock, stop_token __stoken, _Predicate __pred);
@@ -186,7 +186,7 @@ public:
186186
_LIBCPP_AVAILABILITY_SYNC _LIBCPP_HIDE_FROM_ABI bool
187187
wait_for(_Lock& __lock, stop_token __stoken, const chrono::duration<_Rep, _Period>& __rel_time, _Predicate __pred);
188188

189-
# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)
189+
# endif // _LIBCPP_STD_VER >= 20
190190
};
191191

192192
inline condition_variable_any::condition_variable_any() : __mut_(make_shared<mutex>()) {}
@@ -260,7 +260,7 @@ condition_variable_any::wait_for(_Lock& __lock, const chrono::duration<_Rep, _Pe
260260
return wait_until(__lock, chrono::steady_clock::now() + __d, std::move(__pred));
261261
}
262262

263-
# if _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)
263+
# if _LIBCPP_STD_VER >= 20
264264

265265
template <class _Lock, class _Predicate>
266266
bool condition_variable_any::wait(_Lock& __user_lock, stop_token __stoken, _Predicate __pred) {
@@ -341,7 +341,7 @@ bool condition_variable_any::wait_for(
341341
return wait_until(__lock, std::move(__stoken), chrono::steady_clock::now() + __rel_time, std::move(__pred));
342342
}
343343

344-
# endif // _LIBCPP_STD_VER >= 20 && !defined(_LIBCPP_HAS_NO_EXPERIMENTAL_STOP_TOKEN)
344+
# endif // _LIBCPP_STD_VER >= 20
345345

346346
_LIBCPP_EXPORTED_FROM_ABI void notify_all_at_thread_exit(condition_variable&, unique_lock<mutex>);
347347

0 commit comments

Comments
 (0)