Heart 1.4.918.d927d9c
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
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
14 Async(thread) {
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}
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.
AsyncLauncher(QThread *thread)
AsyncLauncher This is base constructor of the AsyncLauncher object.
std::function< bool()> Job
Definition async.h:34
Async(QThread *thread)
Async This is default constructor of the async object.
Definition async.cpp:38
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:78
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13