共用方式為


future::wait_for Method

Blocks the current thread until the associated asynchronous state is ready or until a specified time interval has elapsed.

template<class Rep, class Period>
   future_status wait_for(
      const chrono::duration<Rep, Period>& Rel_time) const;

Parameters

  • Rel_time
    A chrono::duration object that specifies a maximum time interval that the thread blocks.

Return Value

A future_status that indicates the reason for returning.

Remarks

An associated asynchronous state is ready only if its asynchronous provider has stored a return value or stored an exception.

Requirements

Header: future

Namespace: std

See Also

Reference

future Class

<future>