forked from qt-creator/qt-creator
TaskTree: Add synchronous invocation (Tasking::Sync)
Make it possible to mix synchronous and asynchronous calls
inside task tree.
Basically, it's a shortcut for:
bool syncMethod();
Group {
OnGroupSetup([syncMethod] { return syncMethod()
? TaskAction::StopWithDone
: TaskAction::StopWithError; })
}
Please note: similarly to Group, Sync isn't counted as a task
inside taskCount() and doesn't emit TaskTree::progressValueChanged()
when finished. It's being considered as a simple handler
that doesn't last long and shouldn't block the GUI thread.
Otherwise, use AsyncTask instead.
Change-Id: If71c5da2f9b202a69c41a555cc93d314476952f4
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
@@ -244,6 +244,16 @@ public:
|
||||
OnGroupError(const GroupEndHandler &handler) : TaskItem({{}, {}, handler}) {}
|
||||
};
|
||||
|
||||
// Synchronous invocation. Similarly to Group - isn't counted as a task inside taskCount()
|
||||
class QTCREATOR_UTILS_EXPORT Sync : public Group
|
||||
{
|
||||
public:
|
||||
using SynchronousMethod = std::function<bool()>;
|
||||
Sync(const SynchronousMethod &sync)
|
||||
: Group({OnGroupSetup([sync] { return sync() ? TaskAction::StopWithDone
|
||||
: TaskAction::StopWithError; })}) {}
|
||||
};
|
||||
|
||||
QTCREATOR_UTILS_EXPORT extern ParallelLimit sequential;
|
||||
QTCREATOR_UTILS_EXPORT extern ParallelLimit parallel;
|
||||
QTCREATOR_UTILS_EXPORT extern Workflow stopOnError;
|
||||
|
||||
Reference in New Issue
Block a user