Documentation Home >> Headers >> <future> Header >> std::atomic_future class template
[Note] Note

: The std::atomic_future class template is deprecated, and provided for backwards compatibility with earlier releases of just::thread only. It is not part of the C++11 Standard, and should not be used in new programs.

The std::atomic_future class template provides a means of waiting for an asynchronous result from another thread, in conjunction with the std::promise and std::packaged_task class templates which can be used to provide that asynchronous result. Multiple std::atomic_future instances can reference the same asynchronous result.

Instances of std::atomic_future are CopyConstructible and CopyAssignable. You can also move-construct a std::atomic_future from a std::future with the same ResultType.

All accesses to a given instance of std::atomic_future are serialized. It is therefore safe for multiple threads to access the same std::atomic_future instance without risk of a data race. This is in contrast to std::shared_future.

template<typename ResultType>
class atomic_future
{
public:
    atomic_future();
    atomic_future(future<ResultType>&&);
    atomic_future& operator=(future<ResultType>&&);

    atomic_future(atomic_future&&);
    atomic_future(atomic_future const&);
    atomic_future& operator=(atomic_future const&);
    atomic_future& operator=(atomic_future&&);
    ~atomic_future();

    void swap(atomic_future&);

    bool valid() const;

    see description get() const;

    void wait() const;

    template<typename Rep,typename Period>
    future_status wait_for(
        std::chrono::duration<Rep,Period> const&
        relative_time) const;

    template<typename Clock,typename Duration>
    future_status wait_until(
        std::chrono::time_point<Clock,Duration> const&
        absolute_time) const;
};
Header

#include <future>

See Also