Namespaces
Variants

std::promise<R>:: get_future

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
std:: future < R > get_future ( ) ;
(C++11 이후)

동일한 공유 상태와 연관된 future 객체를 반환합니다. * this .

* this 에 공유 상태가 없거나 get_future 가 이미 호출된 경우 예외가 발생합니다. promise-future 통신 채널의 여러 "pop" 끝을 얻으려면 std::future::share 를 사용하십시오.

이 함수에 대한 호출은 set_value , set_exception , set_value_at_thread_exit , 또는 set_exception_at_thread_exit 에 대한 호출과 데이터 경쟁(data race)을 발생시키지 않습니다 (따라서 이들은 서로 동기화할 필요가 없습니다).

매개변수

(없음)

반환값

* this 의 공유 상태를 참조하는 future입니다.

예외

std::future_error 가 다음 조건에서 발생합니다:

  • * this 는 공유 상태를 가지지 않습니다. 오류 코드는 no_state 로 설정됩니다.
  • get_future() 가 동일한 공유 상태를 가진 promise에 대해 이미 호출되었습니다. 오류 코드는 future_already_retrieved 로 설정됩니다.