MillicastSDK 2.0.0
Loading...
Searching...
No Matches
Public Member Functions | List of all members
millicast::Promise< T > Class Template Reference

#include <promise.h>

Public Member Functions

 Promise (std::unique_ptr< detail::PromiseImpl< T > > impl)
 
 Promise (const Promise &)=delete
 
 Promise (Promise &&)=delete
 
Promiseoperator= (const Promise &)=delete
 
Promiseoperator= (Promise &&)=delete
 
Promise< T > & on_result (const typename detail::PromiseResultCbType< T >::Type &cb)
 
Promise< T > & on_error (const std::function< void(const Error &)> &cb)
 
void done ()
 

Detailed Description

template<typename T>
class millicast::Promise< T >

Represents a result of asynchronous operation performed by the client.

New subscriber and viewer APIs return Promise types to allow the caller to set up callbacks for the completion or failure of the operation. The Promise class stores the application-provided callbacks, and upon its destruction causes the callbacks to be set up for execution on the internal client's helper thread.

The callbacks set by the application will never be invoked until the Promise object is destroyed, and all will be invoked on the internal client's helper thread.

Constructor & Destructor Documentation

◆ Promise() [1/3]

template<typename T >
millicast::Promise< T >::Promise ( std::unique_ptr< detail::PromiseImpl< T > >  impl)
inline

◆ Promise() [2/3]

template<typename T >
millicast::Promise< T >::Promise ( const Promise< T > &  )
delete

◆ Promise() [3/3]

template<typename T >
millicast::Promise< T >::Promise ( Promise< T > &&  )
delete

Member Function Documentation

◆ done()

template<typename T >
void millicast::Promise< T >::done ( )
inline

Triggers setting the current callbacks to the SDK internal operation as if the Promise object was destroyed.

Use this function if you capture promise rvalue reference in some wrapper, which may for example want to set the callbacks and then wait until done (to synchronise).

◆ on_error()

template<typename T >
Promise< T > & millicast::Promise< T >::on_error ( const std::function< void(const Error &)> &  cb)
inline

Sets the error callback, invoked when the operation represented by the promise fails.

Parameters
cb- the callback.
Returns
the same promise reference

◆ on_result()

template<typename T >
Promise< T > & millicast::Promise< T >::on_result ( const typename detail::PromiseResultCbType< T >::Type &  cb)
inline

Sets the result callback, invoked when the operation represented by the promise is complete with success.

Parameters
cb- the callback - std::function<void(T&&)>, or std::function<void()> if T=void.
Returns
the same promise reference

◆ operator=() [1/2]

template<typename T >
Promise & millicast::Promise< T >::operator= ( const Promise< T > &  )
delete

◆ operator=() [2/2]

template<typename T >
Promise & millicast::Promise< T >::operator= ( Promise< T > &&  )
delete

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