Namespaces
Variants

std::stop_callback<Callback>:: stop_callback

From cppreference.net
Concurrency support library
Threads
(C++11)
(C++20)
this_thread namespace
(C++11)
(C++11)
Cooperative cancellation
Mutual exclusion
Generic lock management
Condition variables
(C++11)
Semaphores
Latches and Barriers
(C++20)
(C++20)
Futures
(C++11)
(C++11)
(C++11)
Safe reclamation
Hazard pointers
Atomic types
(C++11)
(C++20)
Initialization of atomic types
(C++11) (deprecated in C++20)
(C++11) (deprecated in C++20)
Memory ordering
(C++11) (deprecated in C++26)
Free functions for atomic operations
Free functions for atomic flags
template < class C >
explicit stop_callback ( const std:: stop_token & st, C && cb ) noexcept ( /*see below*/ ) ;
(1) (C++20 이후)
template < class C >
explicit stop_callback ( std:: stop_token && st, C && cb ) noexcept ( /*see below*/ ) ;
(2) (C++20 이후)
stop_callback ( const stop_callback & ) = delete ;
(3) (C++20 이후)
stop_callback ( stop_callback && ) = delete ;
(4) (C++20 이후)

새로운 stop_callback 객체를 생성하며, cb 콜백 함수를 주어진 std::stop_token 의 연관된 중지 상태에 저장하고 등록합니다. 이후 연관된 std::stop_source 에서 중지가 요청되면 호출됩니다.

1) 주어진 st std::stop_token (복사됨)과 주어진 호출 가능 콜백 함수 cb 를 위한 stop_callback 을 생성합니다.
2) 주어진 st std::stop_token (이동된)에 대해, 주어진 호출 가능 콜백 함수 cb 를 사용하여 stop_callback 을 생성합니다.
3,4) stop_callback CopyConstructible MoveConstructible 도 아닙니다.

두 생성자는 오직 Callback C constructible_from 개념을 만족할 때만 오버로드 해결에 참여합니다. std:: constructible_from < Callback, C > . 만약 Callback C 가 개념은 만족하지만 의미적 요구사항을 충족하지 못할 경우, 동작은 정의되지 않습니다.

매개변수

st - stop_callback 객체를 등록할 std::stop_token 객체
cb - 중단이 요청될 경우 호출할 타입

예외

1,2)
noexcept 명세:
noexcept ( std:: is_nothrow_constructible_v < Callback, C > )
주어진 콜백을 stop_callback 객체로 생성자 초기화하는 과정에서 발생하는 모든 예외.

참고 사항

전달된 std::stop_token 에 대해 st. stop_requested ( ) == true 인 경우, 콜백 함수는 생성자가 반환되기 전 현재 스레드에서 호출됩니다.