Thread System 0.3.1
High-performance C++20 thread pool with work stealing and DAG scheduling
Loading...
Searching...
No Matches
kcenon::thread::pool_future< T > Class Template Reference

A future that can be scheduled on a thread pool. More...

#include <future_extensions.h>

Collaboration diagram for kcenon::thread::pool_future< T >:
Collaboration graph

Public Types

using value_type = T
 

Public Member Functions

 pool_future (std::future< T > &&future)
 Construct from a std::future.
 
bool is_ready () const
 Check if the future is ready.
 
get ()
 Wait for the result.
 
template<typename Rep , typename Period >
std::future_status wait_for (const std::chrono::duration< Rep, Period > &timeout)
 Wait for the result with timeout.
 
void wait ()
 Wait until the result is available.
 
bool valid () const
 Check if the future is valid.
 
template<typename F >
auto then (F &&continuation) -> pool_future< std::invoke_result_t< F, T > >
 Chain another operation after this future completes.
 

Private Attributes

std::future< T > future_
 

Detailed Description

template<typename T>
class kcenon::thread::pool_future< T >

A future that can be scheduled on a thread pool.

This class extends std::future with thread pool integration and provides additional utilities for async operations.

Definition at line 31 of file future_extensions.h.

Member Typedef Documentation

◆ value_type

template<typename T >
using kcenon::thread::pool_future< T >::value_type = T

Definition at line 33 of file future_extensions.h.

Constructor & Destructor Documentation

◆ pool_future()

template<typename T >
kcenon::thread::pool_future< T >::pool_future ( std::future< T > && future)
inlineexplicit

Construct from a std::future.

Definition at line 38 of file future_extensions.h.

39 : future_(std::move(future)) {}

Member Function Documentation

◆ get()

template<typename T >
T kcenon::thread::pool_future< T >::get ( )
inline

Wait for the result.

Definition at line 51 of file future_extensions.h.

51 {
52 return future_.get();
53 }

References kcenon::thread::pool_future< T >::future_.

◆ is_ready()

template<typename T >
bool kcenon::thread::pool_future< T >::is_ready ( ) const
inline

Check if the future is ready.

Definition at line 44 of file future_extensions.h.

44 {
45 return future_.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
46 }

References kcenon::thread::pool_future< T >::future_.

◆ then()

template<typename T >
template<typename F >
auto kcenon::thread::pool_future< T >::then ( F && continuation) -> pool_future< std::invoke_result_t< F, T > >

Chain another operation after this future completes.

◆ valid()

template<typename T >
bool kcenon::thread::pool_future< T >::valid ( ) const
inline

Check if the future is valid.

Definition at line 73 of file future_extensions.h.

73 {
74 return future_.valid();
75 }

References kcenon::thread::pool_future< T >::future_.

◆ wait()

template<typename T >
void kcenon::thread::pool_future< T >::wait ( )
inline

Wait until the result is available.

Definition at line 66 of file future_extensions.h.

66 {
67 future_.wait();
68 }

References kcenon::thread::pool_future< T >::future_.

◆ wait_for()

template<typename T >
template<typename Rep , typename Period >
std::future_status kcenon::thread::pool_future< T >::wait_for ( const std::chrono::duration< Rep, Period > & timeout)
inline

Wait for the result with timeout.

Definition at line 59 of file future_extensions.h.

59 {
60 return future_.wait_for(timeout);
61 }

References kcenon::thread::pool_future< T >::future_.

Member Data Documentation

◆ future_


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