File: thread

package info (click to toggle)
cppreference-doc 20170409-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 259,872 kB
  • sloc: xml: 570,184; python: 1,923; php: 520; makefile: 168; sh: 25; cpp: 9; ansic: 9
file content (79 lines) | stat: -rw-r--r-- 2,293 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*  Copyright (C) 2015  Povilas Kanapickas <povilas@radix.lt>

    This file is part of cppreference-doc

    This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
    Unported License. To view a copy of this license, visit
    http://creativecommons.org/licenses/by-sa/3.0/ or send a letter to Creative
    Commons, 444 Castro Street, Suite 900, Mountain View, California, 94041, USA.

    Permission is granted to copy, distribute and/or modify this document
    under the terms of the GNU Free Documentation License, Version 1.3 or
    any later version published by the Free Software Foundation; with no
    Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
*/

#ifndef CPPREFERENCE_THREAD_H
#define CPPREFERENCE_THREAD_H

#if CPPREFERENCE_STDVER>= 2011

namespace std {

class thread {
public:
    class id {
    public:
        id();
    };

    typedef void* native_handle_type; // actually impl-defined

    thread();
    thread(const thread&) = delete;
    thread(thread&& other);
    template <class Function, class ...Args>
    explicit thread(Function&& f, Args&& ... args);
    ~thread();

    thread& operator=(const thread&) = delete;
    thread& operator=(thread&& t);

    bool joinable() const;
    id get_id() const;
    native_handle_type native_handle();
    static unsigned hardware_concurrency();

    void join();
    void detach();
    void swap(thread& t);
};

bool operator==(thread::id lhs, thread::id rhs);
bool operator!=(thread::id lhs, thread::id rhs);
bool operator<(thread::id lhs, thread::id rhs);
bool operator<=(thread::id lhs, thread::id rhs);
bool operator>(thread::id lhs, thread::id rhs);
bool operator>=(thread::id lhs, thread::id rhs);

template<class CharT, class Traits>
basic_ostream<CharT, Traits>&
operator<<(basic_ostream<CharT, Traits>& out, thread::id id);

void swap(thread& lhs, thread& rhs);

namespace this_thread {
void yield();
std::thread::id get_id();
template<class Rep, class Period>
void sleep_for(const std::chrono::duration<Rep, Period>& sleep_duration);
template<class Clock, class Duration>
void sleep_until(const std::chrono::time_point<Clock, Duration>& sleep_time);

} // namespace this_thread

} // namespace std

#endif // CPPREFERENCE_STDVER>= 2011

#endif // CPPREFERENCE_THREAD_H