WPILibC++ 2024.3.2
wpi::promise< T > Class Template Reference

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

#include <wpi/future.h>

Public Member Functions

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

Friends

class PromiseFactory< T >
 

Detailed Description

template<typename T>
class wpi::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::promise< T >::promise ( )
inline

Constructs an empty promise.

◆ promise() [2/3]

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

◆ promise() [3/3]

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

◆ ~promise()

template<typename T >
wpi::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::promise< T >::get_future ( )
inlinenoexcept

Gets a future for this promise.

Returns
The future

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ set_value() [1/2]

template<typename T >
void wpi::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::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::promise< T >::swap ( promise< T > &  oth)
inlinenoexcept

Swaps this promise with another one.

Friends And Related Function Documentation

◆ PromiseFactory< T >

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

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