MT Core (C++)
Core library for replacing C++ standard in project usage
|
Represents the state-setter part of a future. More...
#include <future.hpp>
Classes | |
struct | make_res |
Public Member Functions | |
void | set_val (const T &v) |
T | wait () |
Called by the future, don't call this directly. | |
void | deinit (Allocator &alloc) |
Static Public Member Functions | |
static Result< make_res, AllocationError > | make (Allocator &alloc, std::function< Result< Arc< E >, AllocationError >(Allocator &alloc, Arc< FutureState > &)> getExtra) |
Makes a future and associated future state. | |
Public Attributes | |
std::mutex | mux = {} |
std::condition_variable | cv = {} |
Optional< T > | value = nullopt |
Arc< E > | extra = {} |
Represents the state-setter part of a future.
When you return a future, your code that sets the future value needs to retain this part so it can actually set the future value. ONLY GET THIS USING THE make
FUNCTION! That function will properly link the state to the future. Also, when calling make
it will be wrapped in an Arc which you will need to deinit to clean up memory properly
T | Future result type |
Definition at line 141 of file future.hpp.
|
inline |
Definition at line 164 of file future.hpp.
|
inlinestatic |
Makes a future and associated future state.
Will return both
alloc | Allocator for heap allocations |
getExtra | Callback to get extra state that you may later need to properly work with the future. Don't set it directly on the future state, just return your extra state and the make function will take it from there |
Definition at line 182 of file future.hpp.
|
inline |
Definition at line 147 of file future.hpp.
|
inline |
Called by the future, don't call this directly.
Definition at line 156 of file future.hpp.
std::condition_variable mtcore::thread::FutureState< T, E >::cv = {} |
Definition at line 143 of file future.hpp.
Arc<E> mtcore::thread::FutureState< T, E >::extra = {} |
Definition at line 145 of file future.hpp.
std::mutex mtcore::thread::FutureState< T, E >::mux = {} |
Definition at line 142 of file future.hpp.
Optional<T> mtcore::thread::FutureState< T, E >::value = nullopt |
Definition at line 144 of file future.hpp.