5#ifndef DUNE_COMMON_PARALLEL_FUTURE_HH
6#define DUNE_COMMON_PARALLEL_FUTURE_HH
32 virtual ~FutureBase() =
default;
33 virtual void wait() = 0;
34 virtual bool ready()
const = 0;
35 virtual bool valid()
const = 0;
47 : _future(std::forward<F>(f))
50 virtual void wait()
override
55 virtual bool ready()
const override
57 return _future.ready();
60 virtual bool valid()
const override
62 return _future.valid();
65 virtual T
get()
override{
66 return (T)_future.get();
70 std::unique_ptr<FutureBase> _future;
74 : _future(
std::make_unique<FutureModel<F>>(
std::forward<F>(f)))
77 template<class U, std::enable_if_t<std::is_same<U,T>::value && !std::is_same<T,void>::value>>
96 return _future->get();
104 return _future->ready();
114 return _future->valid();
133 data_(
std::forward<U>(u))
151 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
Reference get(const RAPropertyMapHelper< Reference, PropertyMap > &pmap, const Key &key)
Definition propertymap.hh:84
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:18
A wrapper-class for a object which is ready immediately.
Definition future.hh:122
bool ready() const
Definition future.hh:141
T get()
Definition future.hh:147
PseudoFuture(U &&u)
Definition future.hh:131
PseudoFuture()
Definition future.hh:126
void wait()
Definition future.hh:136
bool valid() const
Definition future.hh:154
Type-erasure for future-like objects. A future-like object is a object satisfying the interface of Fu...
Definition future.hh:28
bool ready() const
Definition future.hh:103
void wait()
wait until the future is ready
Definition future.hh:87
Future(U &&data)
Definition future.hh:78
T get()
Waits until the future is ready and returns the resulting value.
Definition future.hh:95
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:112
Future(F &&f)
Definition future.hh:73
bool ready() const
Definition future.hh:171
bool valid() const
Definition future.hh:183
void get()
Definition future.hh:177
PseudoFuture(bool valid=false)
Definition future.hh:163
void wait()
Definition future.hh:167