QBarrier Class
An asynchronous task that finishes on demand. More...
Header: | #include <qbarriertask.h> |
Inherits: | QObject |
Inherited By: |
Note: All functions in this class are reentrant.
Public Functions
QBarrier(QObject *parent = nullptr) | |
void | advance() |
int | current() const |
bool | isRunning() const |
int | limit() const |
std::optional<QtTaskTree::DoneResult> | result() const |
void | setLimit(int value) |
void | start() |
void | stopWithResult(QtTaskTree::DoneResult result) |
Signals
void | done(QtTaskTree::DoneResult result) |
Detailed Description
QBarrier waits for subsequent calls to advance() to reach the barrier's limit (1 by default). It finishes with DoneResult::Success.
It's often used in QTaskTree recipes to hold the execution of subsequent sequential tasks until some other running task delivers some data which are needed to setup the subsequent tasks.
Member Function Documentation
QBarrier::QBarrier(QObject *parent = nullptr)
Constructs a QBarrier with a given parent.
void QBarrier::advance()
Advances the barrier. If the number of calls to advance() reaches the barrier's limit, the barrier finishes with DoneResult::Success.
int QBarrier::current() const
Returns the current advance count of the barrier.
[private signal]
void QBarrier::done(QtTaskTree::DoneResult result)
This signal is emitted when the barrier finished, passing the final result of the execution.
Note: This is a private signal. It can be used in signal connections but cannot be emitted by the user.
bool QBarrier::isRunning() const
Returns true
if the barrier is currently running; otherwise returns false
.
int QBarrier::limit() const
Returns the current limit of the barrier.
See also setLimit().
std::optional<QtTaskTree::DoneResult> QBarrier::result() const
Returns the result of barrier execution. If barrier wasn't started or it's still running, the returned optional is empty. Otherwise, it returns the result of the last execution.
void QBarrier::setLimit(int value)
Sets the limit to value. After it is started, the barrier finishes when the number of calls to advance() reaches the limit.
See also limit().
void QBarrier::start()
Starts the barrier.
void QBarrier::stopWithResult(QtTaskTree::DoneResult result)
Stops the running barrier unconditionally with a given result. The barrier's limit is ignored.
© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.