Standard library header (C++11)
This header is part of the thread support library.
[edit] Synopsis
namespace std { enum class future_errc { broken_promise = /* implementation-defined */, future_already_retrieved = /* implementation-defined */, promise_already_satisfied = /* implementation-defined */, no_state = /* implementation-defined */ }; enum class launch : /* unspecified */ { async = /* unspecified */, deferred = /* unspecified */, /* implementation-defined */ }; enum class future_status { ready, timeout, deferred }; template struct is_error_code_enum : public true_type { }; error_code make_error_code(future_errc e) noexcept; error_condition make_error_condition(future_errc e) noexcept; const error_category& future_category() noexcept; class future_error; template class promise; template class promise; template class promise; template void swap(promise& x, promise& y) noexcept; template struct uses_allocator<promise, Alloc>; template class future; template class future; template class future; template class shared_future; template class shared_future; template class shared_future; template class packaged_task; // not defined template class packaged_task; template void swap(packaged_task&, packaged_task&) noexcept; template future<invoke_result_t<decay_t, decay_t…>> async(F&& f, Args&&… args); template future<invoke_result_t<decay_t, decay_t…>> async(launch policy, F&& f, Args&&… args); }
[edit] Class std::future_error
namespace std { class future_error : public logic_error { public: explicit future_error(future_errc e); const error_code& code() const noexcept; const char* what() const noexcept; private: error_code ec_; // exposition only }; }
[edit] Class template std::promise
namespace std { template class promise { public: promise(); template promise(allocator_arg_t, const Allocator& a); promise(promise&& rhs) noexcept; promise(const promise&) = delete; ~promise(); // assignment promise& operator=(promise&& rhs) noexcept; promise& operator=(const promise&) = delete; void swap(promise& other) noexcept; // retrieving the result future get_future(); // setting the result void set_value(/* see description */); void set_exception(exception_ptr p); // setting the result with deferred notification void set_value_at_thread_exit(/* see description */); void set_exception_at_thread_exit(exception_ptr p); }; template void swap(promise& x, promise& y) noexcept; template struct uses_allocator<promise, Alloc>; }
[edit] Class template std::future
namespace std { template class future { public: future() noexcept; future(future&&) noexcept; future(const future&) = delete; ~future(); future& operator=(const future&) = delete; future& operator=(future&&) noexcept; shared_future share() noexcept; // retrieving the value /* see description */ get(); // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; }
[edit] Class template std::shared_future
namespace std { template class shared_future { public: shared_future() noexcept; shared_future(const shared_future& rhs) noexcept; shared_future(future&&) noexcept; shared_future(shared_future&& rhs) noexcept; ~shared_future(); shared_future& operator=(const shared_future& rhs) noexcept; shared_future& operator=(shared_future&& rhs) noexcept; // retrieving the value /* see description */ get() const; // functions to check state bool valid() const noexcept; void wait() const; template future_status wait_for(const chrono::duration& rel_time) const; template future_status wait_until(const chrono::time_point& abs_time) const; }; }
[edit] Class template std::packaged_task
namespace std { template class packaged_task; // not defined template class packaged_task { public: // construction and destruction packaged_task() noexcept; template explicit packaged_task(F&& f); ~packaged_task(); // no copy packaged_task(const packaged_task&) = delete; packaged_task& operator=(const packaged_task&) = delete; // move support packaged_task(packaged_task&& rhs) noexcept; packaged_task& operator=(packaged_task&& rhs) noexcept; void swap(packaged_task& other) noexcept; bool valid() const noexcept; // result retrieval future get_future(); // execution void operator()(ArgTypes… ); void make_ready_at_thread_exit(ArgTypes…); void reset(); }; template packaged_task(R (*)(ArgTypes…)) -> packaged_task; template packaged_task(F) -> packaged_task* see description */>; template void swap(packaged_task& x, packaged_task& y) noexcept; }
Source
