mirror of
https://github.com/QuasarApp/Heart.git
synced 2025-04-27 02:04:38 +00:00
added stop and wait functions into async launcher
This commit is contained in:
parent
6055fdc43d
commit
fa092504fc
@ -35,6 +35,7 @@
|
||||
return CONDITION; \
|
||||
|
||||
namespace QH {
|
||||
|
||||
Async::Async(QThread *thread, QObject *ptr):
|
||||
QObject(ptr) {
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
*/
|
||||
|
||||
#include "asynclauncher.h"
|
||||
|
||||
#include <QThread>
|
||||
namespace QH {
|
||||
|
||||
AsyncLauncher::AsyncLauncher(QThread *thread, QObject *ptr):
|
||||
@ -14,7 +16,27 @@ AsyncLauncher::AsyncLauncher(QThread *thread, QObject *ptr):
|
||||
|
||||
|
||||
bool AsyncLauncher::run(const Async::Job &action, bool wait) {
|
||||
if (thread() && !thread()->isRunning()) {
|
||||
thread()->start();
|
||||
}
|
||||
|
||||
return asyncLauncher(action, wait);
|
||||
}
|
||||
|
||||
bool AsyncLauncher::stop() {
|
||||
if (thread() && thread()->isRunning()) {
|
||||
thread()->exit();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool AsyncLauncher::waitForStop() {
|
||||
if (thread() && thread()->isRunning()) {
|
||||
return thread()->wait();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,6 +47,18 @@ public:
|
||||
*/
|
||||
bool run(const Job &action, bool wait = false);
|
||||
|
||||
/**
|
||||
* @brief stop This method stop the work thread of this object.
|
||||
* @return true if the thread is stopped.
|
||||
*/
|
||||
bool stop();
|
||||
|
||||
/**
|
||||
* @brief waitForStop This method wait for the thread of this object is stopped.
|
||||
* @return true if the thread is stopped.
|
||||
*/
|
||||
bool waitForStop();
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ public:
|
||||
/**
|
||||
* @brief stop This method stops the render loop.
|
||||
*/
|
||||
void stop();
|
||||
virtual void stop();
|
||||
|
||||
/**
|
||||
* @brief isRun This method returns the state of the render loop.
|
||||
|
Loading…
x
Reference in New Issue
Block a user