Standard library header <thread> (C++11)
From cppreference.net
이 헤더는 스레드 지원 라이브러리의 일부입니다.
포함 파일 |
||
|
(C++20)
|
3방향 비교 연산자 지원 | |
네임스페이스 |
||
this_thread
|
현재 실행 스레드에 접근하는 함수 제공 | |
클래스 |
||
|
(C++11)
|
별도 스레드 관리
(클래스) |
|
|
(C++20)
|
std::thread
자동 조인 및 취소 지원 포함
(클래스) |
|
|
std::hash
특수화
(클래스 템플릿 특수화) |
||
함수 |
||
|
(C++11)
|
std::swap
알고리즘 특수화
(함수) |
|
|
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20에서 제거됨)
(C++20)
|
두 개의
thread::id
객체 비교
(함수) |
|
thread::id
객체 직렬화
(함수 템플릿) |
||
std::this_thread
네임스페이스에 정의됨
|
||
|
(C++11)
|
구현체에 스레드 실행 재조정 제안
(함수) |
|
|
(C++11)
|
현재 스레드의 스레드 ID 반환
(함수) |
|
|
(C++11)
|
현재 스레드의 실행을 지정된 시간 동안 중지
(함수) |
|
|
(C++11)
|
현재 스레드의 실행을 지정된 시간점까지 중지
(함수) |
|
시놉시스
#include <compare> namespace std { // 클래스 thread class thread; void swap(thread& x, thread& y) noexcept; // 클래스 jthread class jthread; // 네임스페이스 this_thread namespace this_thread { thread::id get_id() noexcept; void yield() noexcept; template<class Clock, class Duration> void sleep_until(const chrono::time_point<Clock, Duration>& abs_time); template<class Rep, class Period> void sleep_for(const chrono::duration<Rep, Period>& rel_time); } }
클래스 std::thread
namespace std { class thread { public: // 클래스 thread::id class id; using native_handle_type = /* 구현 정의 */; // 생성/복사/소멸 thread() noexcept; template<class F, class... Args> explicit thread(F&& f, Args&&... args); ~thread(); thread(const thread&) = delete; thread(thread&&) noexcept; thread& operator=(const thread&) = delete; thread& operator=(thread&&) noexcept; // 멤버 함수 void swap(thread&) noexcept; bool joinable() const noexcept; void join(); void detach(); id get_id() const noexcept; native_handle_type native_handle(); // 정적 멤버 static unsigned int hardware_concurrency() noexcept; }; }
클래스 std::jthread
namespace std { class jthread { public: // 타입 using id = thread::id; using native_handle_type = thread::native_handle_type; // 생성자, 이동, 할당 jthread() noexcept; template<class F, class... Args> explicit jthread(F&& f, Args&&... args); ~jthread(); jthread(const jthread&) = delete; jthread(jthread&&) noexcept; jthread& operator=(const jthread&) = delete; jthread& operator=(jthread&&) noexcept; // 멤버 함수 void swap(jthread&) noexcept; bool joinable() const noexcept; void join(); void detach(); id get_id() const noexcept; native_handle_type native_handle(); // 정지 토큰 처리 stop_source get_stop_source() noexcept; stop_token get_stop_token() const noexcept; bool request_stop() noexcept; // 특수화된 알고리즘 friend void swap(jthread& lhs, jthread& rhs) noexcept; // 정적 멤버 static unsigned int hardware_concurrency() noexcept; private: stop_source ssource; // 설명 전용 }; }
클래스 std::thread::id
namespace std { class thread::id { public: id() noexcept; }; bool operator==(thread::id x, thread::id y) noexcept; strong_ordering operator<=>(thread::id x, thread::id y) noexcept; template<class CharT, class Traits> basic_ostream<CharT, Traits>& operator<<(basic_ostream<CharT, Traits>& out, thread::id id); template<class CharT> struct formatter<thread::id, CharT>; // 해시 지원 template<class T> struct hash; template<> struct hash<thread::id>; }