1 | // -*- C++ -*- |
2 | //===----------------------------------------------------------------------===// |
3 | // |
4 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
5 | // See https://llvm.org/LICENSE.txt for license information. |
6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
7 | // |
8 | //===----------------------------------------------------------------------===// |
9 | |
10 | #ifndef _LIBCPP_THREAD |
11 | #define _LIBCPP_THREAD |
12 | |
13 | /* |
14 | |
15 | thread synopsis |
16 | |
17 | namespace std |
18 | { |
19 | |
20 | class thread |
21 | { |
22 | public: |
23 | class id; |
24 | typedef pthread_t native_handle_type; |
25 | |
26 | thread() noexcept; |
27 | template <class F, class ...Args> explicit thread(F&& f, Args&&... args); |
28 | ~thread(); |
29 | |
30 | thread(const thread&) = delete; |
31 | thread(thread&& t) noexcept; |
32 | |
33 | thread& operator=(const thread&) = delete; |
34 | thread& operator=(thread&& t) noexcept; |
35 | |
36 | void swap(thread& t) noexcept; |
37 | |
38 | bool joinable() const noexcept; |
39 | void join(); |
40 | void detach(); |
41 | id get_id() const noexcept; |
42 | native_handle_type native_handle(); |
43 | |
44 | static unsigned hardware_concurrency() noexcept; |
45 | }; |
46 | |
47 | void swap(thread& x, thread& y) noexcept; |
48 | |
49 | class thread::id |
50 | { |
51 | public: |
52 | id() noexcept; |
53 | }; |
54 | |
55 | bool operator==(thread::id x, thread::id y) noexcept; |
56 | bool operator!=(thread::id x, thread::id y) noexcept; // removed in C++20 |
57 | bool operator< (thread::id x, thread::id y) noexcept; // removed in C++20 |
58 | bool operator<=(thread::id x, thread::id y) noexcept; // removed in C++20 |
59 | bool operator> (thread::id x, thread::id y) noexcept; // removed in C++20 |
60 | bool operator>=(thread::id x, thread::id y) noexcept; // removed in C++20 |
61 | strong_ordering operator<=>(thread::id x, thread::id y) noexcept; // C++20 |
62 | |
63 | template<class charT, class traits> |
64 | basic_ostream<charT, traits>& |
65 | operator<<(basic_ostream<charT, traits>& out, thread::id id); |
66 | |
67 | template<class charT> |
68 | struct formatter<thread::id, charT>; |
69 | |
70 | namespace this_thread |
71 | { |
72 | |
73 | thread::id get_id() noexcept; |
74 | |
75 | void yield() noexcept; |
76 | |
77 | template <class Clock, class Duration> |
78 | void sleep_until(const chrono::time_point<Clock, Duration>& abs_time); |
79 | |
80 | template <class Rep, class Period> |
81 | void sleep_for(const chrono::duration<Rep, Period>& rel_time); |
82 | |
83 | } // this_thread |
84 | |
85 | } // std |
86 | |
87 | */ |
88 | |
89 | #if __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
90 | # include <__cxx03/thread> |
91 | #else |
92 | # include <__config> |
93 | |
94 | # if _LIBCPP_HAS_THREADS |
95 | |
96 | # include <__thread/this_thread.h> |
97 | # include <__thread/thread.h> |
98 | |
99 | # if _LIBCPP_STD_VER >= 20 |
100 | # include <__thread/jthread.h> |
101 | # endif |
102 | |
103 | # if _LIBCPP_STD_VER >= 23 |
104 | # include <__thread/formatter.h> |
105 | # endif |
106 | |
107 | # include <version> |
108 | |
109 | // standard-mandated includes |
110 | |
111 | // [thread.syn] |
112 | # include <compare> |
113 | |
114 | # if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) |
115 | # pragma GCC system_header |
116 | # endif |
117 | |
118 | # endif // _LIBCPP_HAS_THREADS |
119 | |
120 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 17 |
121 | # include <chrono> |
122 | # endif |
123 | |
124 | # if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20 |
125 | # include <cstring> |
126 | # include <functional> |
127 | # include <new> |
128 | # include <system_error> |
129 | # include <type_traits> |
130 | # endif |
131 | #endif // __cplusplus < 201103L && defined(_LIBCPP_USE_FROZEN_CXX03_HEADERS) |
132 | |
133 | #endif // _LIBCPP_THREAD |
134 | |