ThreadSchedule 1.0.0
Modern C++ thread management library
Loading...
Searching...
No Matches
threadschedule::FutureWithErrorHandler< T > Class Template Reference

Future wrapper that provides error callback support. More...

#include <error_handler.hpp>

Inheritance diagram for threadschedule::FutureWithErrorHandler< T >:
[legend]

Public Member Functions

 FutureWithErrorHandler (std::future< T > future)
 FutureWithErrorHandler (FutureWithErrorHandler const &)=delete
auto operator= (FutureWithErrorHandler const &) -> FutureWithErrorHandler &=delete
 FutureWithErrorHandler (FutureWithErrorHandler &&)=default
auto operator= (FutureWithErrorHandler &&) -> FutureWithErrorHandler &=default
auto on_error (std::function< void(std::exception_ptr)> callback) -> FutureWithErrorHandler &
 Attach an error callback.
auto get () -> T
 Get the result, calling error callback if exception is thrown.
void wait () const
 Wait for the future to complete.
template<typename Rep, typename Period>
auto wait_for (std::chrono::duration< Rep, Period > const &timeout_duration) const
 Wait for the future with timeout.
template<typename Clock, typename Duration>
auto wait_until (std::chrono::time_point< Clock, Duration > const &timeout_time) const
 Wait until a specific time point.
auto valid () const -> bool
 Check if the future is valid.

Detailed Description

template<typename T>
class threadschedule::FutureWithErrorHandler< T >

Future wrapper that provides error callback support.

Extends std::future with the ability to attach error callbacks.

Definition at line 198 of file error_handler.hpp.

Constructor & Destructor Documentation

◆ FutureWithErrorHandler()

template<typename T>
threadschedule::FutureWithErrorHandler< T >::FutureWithErrorHandler ( std::future< T > future)
inlineexplicit

Definition at line 201 of file error_handler.hpp.

Member Function Documentation

◆ get()

template<typename T>
auto threadschedule::FutureWithErrorHandler< T >::get ( ) -> T
inline

Get the result, calling error callback if exception is thrown.

Definition at line 226 of file error_handler.hpp.

◆ on_error()

template<typename T>
auto threadschedule::FutureWithErrorHandler< T >::on_error ( std::function< void(std::exception_ptr)> callback) -> FutureWithErrorHandler&
inline

Attach an error callback.

Parameters
callbackFunction to call if the future throws
Returns
Reference to this for chaining

Definition at line 216 of file error_handler.hpp.

◆ valid()

template<typename T>
auto threadschedule::FutureWithErrorHandler< T >::valid ( ) const -> bool
inlinenodiscard

Check if the future is valid.

Definition at line 271 of file error_handler.hpp.

◆ wait()

template<typename T>
void threadschedule::FutureWithErrorHandler< T >::wait ( ) const
inline

Wait for the future to complete.

Definition at line 245 of file error_handler.hpp.

◆ wait_for()

template<typename T>
template<typename Rep, typename Period>
auto threadschedule::FutureWithErrorHandler< T >::wait_for ( std::chrono::duration< Rep, Period > const & timeout_duration) const
inline

Wait for the future with timeout.

Definition at line 254 of file error_handler.hpp.

◆ wait_until()

template<typename T>
template<typename Clock, typename Duration>
auto threadschedule::FutureWithErrorHandler< T >::wait_until ( std::chrono::time_point< Clock, Duration > const & timeout_time) const
inline

Wait until a specific time point.

Definition at line 263 of file error_handler.hpp.


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