WPILibC++ 2027.0.0-alpha-4
Loading...
Searching...
No Matches
wpi::util::promise< T > Class Template Reference

A lightweight version of std::promise. More...

#include <wpi/util/future.hpp>

Public Member Functions

 promise ()
 Constructs an empty promise.
 promise (promise &&oth) noexcept
 promise (const promise &)=delete
 ~promise ()
 Sets the promised value to a default-constructed T if not already set.
promiseoperator= (promise &&oth) noexcept
promiseoperator= (const promise &)=delete
void swap (promise &oth) noexcept
 Swaps this promise with another one.
future< T > get_future () noexcept
 Gets a future for this promise.
void set_value (const T &value)
 Sets the promised value.
void set_value (T &&value)
 Sets the promised value.

Friends

class PromiseFactory< T >

Detailed Description

template<typename T>
class wpi::util::promise< T >

A lightweight version of std::promise.

Use PromiseFactory::CreatePromise() to create.

Template Parameters
Tthe "return" type

Constructor & Destructor Documentation

◆ promise() [1/3]

template<typename T>
wpi::util::promise< T >::promise ( )
inline

Constructs an empty promise.

◆ promise() [2/3]

template<typename T>
wpi::util::promise< T >::promise ( promise< T > && oth)
inlinenoexcept

◆ promise() [3/3]

template<typename T>
wpi::util::promise< T >::promise ( const promise< T > & )
delete

◆ ~promise()

template<typename T>
wpi::util::promise< T >::~promise ( )
inline

Sets the promised value to a default-constructed T if not already set.

Member Function Documentation

◆ get_future()

template<typename T>
future< T > wpi::util::promise< T >::get_future ( )
inlinenoexcept

Gets a future for this promise.

Returns
The future

◆ operator=() [1/2]

template<typename T>
promise & wpi::util::promise< T >::operator= ( const promise< T > & )
delete

◆ operator=() [2/2]

template<typename T>
promise & wpi::util::promise< T >::operator= ( promise< T > && oth)
inlinenoexcept

◆ set_value() [1/2]

template<typename T>
void wpi::util::promise< T >::set_value ( const T & value)
inline

Sets the promised value.

Only effective once (subsequent calls will be ignored).

Parameters
valueThe value to provide to the waiting future

◆ set_value() [2/2]

template<typename T>
void wpi::util::promise< T >::set_value ( T && value)
inline

Sets the promised value.

Only effective once (subsequent calls will be ignored).

Parameters
valueThe value to provide to the waiting future

◆ swap()

template<typename T>
void wpi::util::promise< T >::swap ( promise< T > & oth)
inlinenoexcept

Swaps this promise with another one.

◆ PromiseFactory< T >

template<typename T>
friend class PromiseFactory< T >
friend

The documentation for this class was generated from the following file: