Movatterモバイル変換


[0]ホーム

URL:


cppreference.com
Namespaces
Variants
    Actions

      std::shared_future<T>::wait_until

      From cppreference.com
      <cpp‎ |thread‎ |shared future

      [edit template]
       
       
      Concurrency support library
      Threads
      (C++11)
      (C++20)
      this_thread namespace
      (C++11)
      (C++11)
      (C++11)
      Cooperative cancellation
      Mutual exclusion
      Generic lock management
      (C++11)
      (C++11)
      (C++11)
      (C++11)
      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 Clock,class Duration>
      std::future_status wait_until(conststd::chrono::time_point<Clock,Duration>& timeout_time)const;
      (since C++11)

      wait_until waits for a result to become available. It blocks until specifiedtimeout_time has been reached or the result becomes available, whichever comes first. The return value indicates whywait_until returned.

      If the future is the result of a call toasync that used lazy evaluation, this function returns immediately without waiting.

      The behavior is undefined ifvalid() isfalse before the call to this function, orClock does not meet theClock requirements.The programs is ill-formed ifstd::chrono::is_clock_v<Clock> isfalse.(since C++20)

      Contents

      [edit]Parameters

      timeout_time - maximum time point to block until

      [edit]Return value

      Constant Explanation
      future_status::deferred The shared state contains a deferred function using lazy evaluation, so the result will be computed only when explicitly requested
      future_status::ready The result is ready
      future_status::timeout The timeout has expired

      [edit]Exceptions

      Any exception thrown by clock, time_point, or duration during the execution (clocks, time points, and durations provided by the standard library never throw).

      [edit]Notes

      The implementations are encouraged to detect the case whenvalid()==false before the call and throw astd::future_error with an error condition offuture_errc::no_state.

      The standard recommends that the clock tied totimeout_time be used to measure time; that clock is not required to be a monotonic clock. There are no guarantees regarding the behavior of this function if the clock is adjusted discontinuously, but the existing implementations converttimeout_time fromClock tostd::chrono::system_clock and delegate to POSIXpthread_cond_timedwait so that the wait honors adjustments to the system clock, but not to the user-providedClock. In any case, the function also may wait for longer than until aftertimeout_time has been reached due to scheduling or resource contention delays.


      [edit]Example

      This section is incomplete
      Reason: no example

      [edit]See also

      waits for the result to become available
      (public member function)[edit]
      waits for the result, returns if it is not available for the specified timeout duration
      (public member function)[edit]
      Retrieved from "https://en.cppreference.com/mwiki/index.php?title=cpp/thread/shared_future/wait_until&oldid=132985"

      [8]ページ先頭

      ©2009-2025 Movatter.jp