64 return _future.valid() &&
65 _future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
81 if(_future.wait_for(std::chrono::milliseconds(
timeoutMs)) ==
82 std::future_status::ready) {
92 if(_future.valid()) _future.wait();
102 if(_future.wait_for(std::chrono::milliseconds(
timeoutMs)) ==
103 std::future_status::ready) {
114 return _future.valid();
118 mutable std::future<T> _future;
148 return _future.valid() &&
149 _future.wait_for(std::chrono::seconds(0)) == std::future_status::ready;
164 if(_future.wait_for(std::chrono::milliseconds(
timeoutMs)) ==
165 std::future_status::ready) {
176 if(_future.valid()) _future.wait();
186 if(_future.wait_for(std::chrono::milliseconds(
timeoutMs)) ==
187 std::future_status::ready) {
198 return _future.valid();
202 mutable std::future<void> _future;
Lightweight error code wrapper for the promeki library.
Definition error.h:39
@ Timeout
Operation timed out.
Definition error.h:78
@ Ok
No error.
Definition error.h:51
@ Invalid
Invalid value or argument (EINVAL).
Definition error.h:66
Error result(unsigned int timeoutMs=0)
Waits for completion and returns the status.
Definition future.h:158
bool isValid() const
Returns whether this Future holds a valid shared state.
Definition future.h:197
bool isReady() const
Checks whether the result is ready without blocking.
Definition future.h:147
Error waitForFinished(unsigned int timeoutMs)
Blocks until the result is ready or the timeout expires.
Definition future.h:184
Future(std::future< void > &&f)
Constructs a Future from a std::future.
Definition future.h:133
void waitForFinished()
Blocks until the result is ready.
Definition future.h:175
Future()=default
Constructs an invalid (empty) Future.
~Future()=default
Destructor.
Asynchronous result wrapping std::future<T>.
Definition future.h:39
Future()=default
Constructs an invalid (empty) Future.
Future(std::future< T > &&f)
Constructs a Future from a std::future.
Definition future.h:45
bool isReady() const
Checks whether the result is ready without blocking.
Definition future.h:63
Result< T > result(unsigned int timeoutMs=0)
Returns the result, blocking until available or timeout.
Definition future.h:76
void waitForFinished()
Blocks until the result is ready.
Definition future.h:91
bool isValid() const
Returns whether this Future holds a valid shared state.
Definition future.h:113
Future(Future &&other)=default
Move constructor.
~Future()=default
Destructor.
Future & operator=(Future &&other)=default
Move assignment.
Error waitForFinished(unsigned int timeoutMs)
Blocks until the result is ready or the timeout expires.
Definition future.h:100
Dynamic array container wrapping std::vector.
Definition list.h:40
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19