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_);
191 #endif // DUNE_COMMON_PARALLEL_FUTURE_HH PseudoFuture(U &&u)
Definition: future.hh:133
void wait()
Definition: future.hh:138
PseudoFuture()
Definition: future.hh:128
bool valid() const
Definition: future.hh:185
void wait()
Definition: future.hh:169
PseudoFuture(bool valid=false)
Definition: future.hh:165
This exception is thrown when ready(), wait() or get() is called on an invalid future. A future is valid until get() is called and if it is not default-constructed and it was not moved from.
Definition: future.hh:19
Dune namespace
Definition: alignedallocator.hh:12
bool ready() const
Definition: future.hh:105
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
void wait()
wait until the future is ready
Definition: future.hh:89
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition: future.hh:30
A few common exception classes.
bool ready() const
Definition: future.hh:143
bool valid() const
Checks whether the future is valid. I.e. ‘get()’ was not called on that future and when it was not ...
Definition: future.hh:114
A wrapper-class for a object which is ready immediately.
Definition: future.hh:24
Future(U &&data)
Definition: future.hh:80
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:375
bool ready() const
Definition: future.hh:173
bool valid() const
Definition: future.hh:156
Future(F &&f)
Definition: future.hh:75