14#include <QtCore/QSemaphore>
15#include <QtCore/QMutex>
16#include <QtCore/QThread>
17#include <QtCore/QThreadPool>
115 std::atomic<Status> m_operationStatus;
117 QSemaphore m_runningStateSemaphore;
118 mutable QMutex m_statusMutex;
119 mutable QRecursiveMutex m_handlerMutex;
General implementation of iproc::ITaskPromise.
static CTaskState RunSequence(Sequence &&functions, std::unique_ptr< istd::IPolymorphic > &&statePtr=nullptr)
Run list of functions in the sequence.
bool IsCanceled() const
Check if this promise is canceled.
CTaskState StartAsyncTask()
Start async .
static CTaskState RunPooled(QThreadPool &threadPool, std::function< bool(const CGeneralTaskPromise &)> func, int priority=0)
Run concurrent some code thread pool.
void SetCancel()
Say this promise to be canceled.
virtual void OnFinalStatusSet(Status status)
Called when the final status was set.
CGeneralTaskPromise()
Construct promise in canceled state.
~CGeneralTaskPromise() override
void SetFinalStatus(Status status)
Set final state of this operation promise.
ITaskPromise::Status WaitForFinished(const double *periodPtr=nullptr) override
Wait for operation finished.
void OnCanceledByUser() override
Called when user forced to cancel this operation.
void InitRunningState()
Reset current.
bool SetReadyHandler(Handler *handlerPtr) override
Set final handler.
static CTaskState RunConcurrent(std::function< bool(const CGeneralTaskPromise &)> func, QThread::Priority priority=QThread::Priority::InheritPriority)
Run concurrent some code in new thread.
Status GetStatus() const override
Get current state of operation.
std::list< std::function< CTaskState()> > Sequence
Represent state of asynchronous operation.
Interface for some operation promise.
This namespace containes interfaces and implementation of data processing concepts.