Heart 1.3.877.fa09250
Heart is base back end library for your c++ Qt projects.
asynclauncher.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2021-2025 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#include "asynclauncher.h"
9
10#include <QThread>
11namespace QH {
12
13AsyncLauncher::AsyncLauncher(QThread *thread, QObject *ptr):
14 Async(thread, ptr) {
15}
16
17
18bool AsyncLauncher::run(const Async::Job &action, bool wait) {
19 if (thread() && !thread()->isRunning()) {
20 thread()->start();
21 }
22
23 return asyncLauncher(action, wait);
24}
25
27 if (thread() && thread()->isRunning()) {
28 thread()->exit();
29 }
30
31 return true;
32}
33
35 if (thread() && thread()->isRunning()) {
36 return thread()->wait();
37 }
38
39 return true;
40}
41
42}
AsyncLauncher(QThread *thread, QObject *ptr=nullptr)
AsyncLauncher This is base constructor of the AsyncLauncher object.
bool run(const Job &action, bool wait=false)
run This method run the action function in the work thread of this object.
bool stop()
stop This method stop the work thread of this object.
bool waitForStop()
waitForStop This method wait for the thread of this object is stopped.
The Async class This is bundle of async templates and async wrappers.
Definition async.h:25
std::function< bool()> Job
Definition async.h:34
bool asyncLauncher(const Job &job, bool await=false, bool freaze=true) const
asyncLauncher This method invoke a job on the thread (using the asyncHandler method) of this object.
Definition async.cpp:81
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13