3#ifndef DUNE_COMMON_PARALLEL_FUTURE_HH
4#define DUNE_COMMON_PARALLEL_FUTURE_HH
30 virtual ~FutureBase() =
default;
31 virtual void wait() = 0;
32 virtual bool ready()
const = 0;
33 virtual bool valid()
const = 0;
45 : _future(std::forward<F>(f))
48 virtual void wait()
override
53 virtual bool ready()
const override
55 return _future.ready();
58 virtual bool valid()
const override
60 return _future.valid();
63 virtual T
get()
override{
64 return (T)_future.get();
68 std::unique_ptr<FutureBase> _future;
72 : _future(std::make_unique<FutureModel<F>>(std::forward<F>(f)))
75 template<class U, std::enable_if_t<std::is_same<U,T>::value && !std::is_same<T,void>::value>>
94 return _future->get();
102 return _future->ready();
112 return _future->valid();
131 data_(std::forward<U>(u))
149 return std::forward<T>(data_);
167 DUNE_THROW(InvalidFutureException,
"The PseudoFuture is not valid");
171 DUNE_THROW(InvalidFutureException,
"The PseudoFuture is not valid");
177 DUNE_THROW(InvalidFutureException,
"The PseudoFuture is not valid");
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition: future.hh:26
bool ready() const
Definition: future.hh:101
void wait()
wait until the future is ready
Definition: future.hh:85
T get()
Waits until the future is ready and returns the resulting value.
Definition: future.hh:93
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:110
This exception is thrown when ready(), wait() or get() is called on an invalid future....
Definition: future.hh:16
Default exception if a function was called while the object is not in a valid state for that function...
Definition: exceptions.hh:279
A wrapper-class for a object which is ready immediately.
Definition: future.hh:120
A few common exception classes.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:216
Dune namespace.
Definition: alignedallocator.hh:11