public member function
<future>

std::shared_future::wait

void wait() const;
Wait for ready
Waits for the shared state to be ready.

如果*共享状态*尚未就绪(即提供者尚未设置其值或异常),则函数会阻塞调用线程,并等待其就绪。

Once the shared state is ready, the function unblocks and returns without reading its value nor throwing its set exception (if any).

All visible side effects are synchronized between the point the provider makes the shared state ready and the return of this function, but note that no synchronization exists among the potential multiple functions returning on this event (in case of multiple shared_future objects were waiting for the same shared state).

参数



返回值



数据竞争

shared_future 对象被访问。
The shared state is accessed as an atomic operation relative to the previous modifying operation by the provider, but not in relation to multiple accesses from shared_future objects.

异常安全

Calling this member function on a shared_future object that is not valid, produces undefined behavior (although library implementations may detect this and throw future_error with a no_state error condition).

另见