3 #include <Poco/Exception.h>
4 #include <Poco/Mutex.h>
6 #include "util/AsyncWork.h"
16 template <
typename Result = Poco::Vo
id>
19 typedef Poco::SharedPtr<AbstractAsyncWork<Result>> Ptr;
30 Poco::Nullable<Result>
result()
const override;
33 mutable Poco::FastMutex m_lock;
34 Poco::Nullable<Result> m_result;
40 throw Poco::NotImplementedException(
"cannot set result for Void operation");
46 poco_assert(m_result.isNull());
50 template <
typename Result>
53 Poco::FastMutex::ScopedLock guard(m_lock);
55 if (!m_result.isNull())
56 throw Poco::IllegalStateException(
"result is already set");
61 template <
typename Result>
64 Poco::FastMutex::ScopedLock guard(m_lock);
Poco::Nullable< Result > result() const override
Definition: AbstractAsyncWork.h:62
AbstractAsyncWork provides a generic implementation of method result() and a supplementary method set...
Definition: AbstractAsyncWork.h:17
AsyncWork is an interface allowing to wait until an asynchronous operation finishes. It is also possible to force-stop it by calling cancel().
Definition: AsyncWork.h:21
void setResult(const Result &result)
Set result of the operation. The result can be set only once.
Definition: AbstractAsyncWork.h:51