5#ifndef DUNE_COMMON_PARALLEL_FUTURE_HH
6#define DUNE_COMMON_PARALLEL_FUTURE_HH
34 virtual ~FutureBase() =
default;
35 virtual void wait() = 0;
36 virtual bool ready()
const = 0;
37 virtual bool valid()
const = 0;
49 : _future(std::forward<F>(f))
52 virtual void wait()
override
57 virtual bool ready()
const override
59 return _future.ready();
62 virtual bool valid()
const override
64 return _future.valid();
67 virtual T
get()
override{
68 return (T)_future.get();
72 std::unique_ptr<FutureBase> _future;
76 : _future(
std::make_unique<FutureModel<F>>(
std::forward<F>(f)))
79 template<class U, std::enable_if_t<std::is_same<U,T>::value && !std::is_same<T,void>::value>>
98 return _future->get();
106 return _future->ready();
116 return _future->valid();
135 data_(
std::forward<U>(u))
153 return std::forward<T>(data_);
A few common exception classes.
#define DUNE_THROW(E, m)
Definition exceptions.hh:218
Dune namespace.
Definition alignedallocator.hh:13
constexpr auto get(std::integer_sequence< T, II... >, std::integral_constant< std::size_t, pos >={})
Return the entry at position pos of the given sequence.
Definition integersequence.hh:22
Default exception if a function was called while the object is not in a valid state for that function...
Definition exceptions.hh:281
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition future.hh:20
A wrapper-class for a object which is ready immediately.
Definition future.hh:124
bool ready() const
Definition future.hh:143
T get()
Definition future.hh:149
PseudoFuture(U &&u)
Definition future.hh:133
PseudoFuture()
Definition future.hh:128
void wait()
Definition future.hh:138
bool valid() const
Definition future.hh:156
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition future.hh:30
bool ready() const
Definition future.hh:105
void wait()
wait until the future is ready
Definition future.hh:89
Future(U &&data)
Definition future.hh:80
T get()
Waits until the future is ready and returns the resulting value.
Definition future.hh:97
bool valid() const
Checks whether the future is valid. I.e. ‘get()’ was not called on that future and when it was not de...
Definition future.hh:114
Future(F &&f)
Definition future.hh:75
bool ready() const
Definition future.hh:173
bool valid() const
Definition future.hh:185
void get()
Definition future.hh:179
PseudoFuture(bool valid=false)
Definition future.hh:165
void wait()
Definition future.hh:169