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