MT Core (C++)
Core library for replacing C++ standard in project usage
Loading...
Searching...
No Matches
mtcore::thread::Future< T, E > Struct Template Reference

Represents a value that will be made available in the future Can wait on the value for when it is ready. More...

#include <future.hpp>

Inheritance diagram for mtcore::thread::Future< T, E >:
Collaboration diagram for mtcore::thread::Future< T, E >:

Public Member Functions

Result< Future, ArcErroracquire (Allocator &alloc)
 Acquires a new reference to the future (if you want multiple parts of your code to read it)
 
wait ()
 Blocks to wait for result.
 
void deinit (Allocator &alloc)
 Cleans up future.
 

Public Attributes

Arc< FutureState< T, E > > state
 

Detailed Description

template<typename T, typename E = void>
struct mtcore::thread::Future< T, E >

Represents a value that will be made available in the future Can wait on the value for when it is ready.

Atomic Reference Counting

  • 1-2 for state

Condition Variables:

  • 1 condition variables for receiving

Non-Blocking Availability:

  • None
Template Parameters
TValue that will be returned
EExtra state in the underlying state

Definition at line 50 of file future.hpp.

Member Function Documentation

◆ acquire()

template<typename T, typename E = void>
Result< Future, ArcError > mtcore::thread::Future< T, E >::acquire ( Allocator & alloc)
inline

Acquires a new reference to the future (if you want multiple parts of your code to read it)

Parameters
allocAllocator for arc

Definition at line 57 of file future.hpp.

57 {
58 auto res = state.acquire(alloc);
59 if (res.is_error()) {
60 return res.error();
61 }
62 return Future{.state = res.value()};
63 }
Represents a value that will be made available in the future Can wait on the value for when it is rea...
Definition future.hpp:50
Result< Future, ArcError > acquire(Allocator &alloc)
Acquires a new reference to the future (if you want multiple parts of your code to read it)
Definition future.hpp:57

◆ deinit()

template<typename T, typename E = void>
void mtcore::thread::Future< T, E >::deinit ( Allocator & alloc)
inline

Cleans up future.

Parameters
allocAllocator for cleaning up Arc (if we were the last to hold it)

Definition at line 74 of file future.hpp.

74{ state.deinit(alloc); }
void deinit(Allocator &alloc)
Cleans up future.
Definition future.hpp:74

◆ wait()

template<typename T, typename E = void>
T mtcore::thread::Future< T, E >::wait ( )
inlinenodiscard

Blocks to wait for result.

Definition at line 68 of file future.hpp.

68{ return state->wait(); }
T wait()
Blocks to wait for result.
Definition future.hpp:68

Member Data Documentation

◆ state

template<typename T, typename E = void>
Arc<FutureState<T, E> > mtcore::thread::Future< T, E >::state

Definition at line 51 of file future.hpp.


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