Heart 1.3.864.4bd6f7b
Heart is base back end library for your c++ Qt projects.
async.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-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#ifndef ASYNC_H
9#define ASYNC_H
10#include <QObject>
11#include <functional>
12#include "config.h"
13#include "heart_global.h"
14
15namespace QH {
16
25class HEARTSHARED_EXPORT Async: public QObject {
26
27 Q_OBJECT
28
29public:
34 using Job = std::function<bool()>;
35
44 bool asyncLauncher(const Job &job, bool await = false, bool freaze = true) const;
45
46protected:
53 Async(QThread* thread, QObject* ptr = nullptr);
54
59 ~Async();
60
68 bool waitFor(bool* condition, int timeout = WAIT_TIME, bool freaze = true) const;
69
77 bool waitFor(const Job &condition, int timeout = WAIT_TIME, bool freaze = true) const;
78
79private slots:
80
136 void asyncHandler (QH::Async::Job job,
137 bool* endOfWork = nullptr,
138 bool* resultOfWork = nullptr) const;
139
140
141private:
148 void threadAnalize(QThread* thread);
149};
150
151}
152
154#endif // ASYNC_H
The Async class This is bundle of async templates and async wrappers.
Definition async.h:25
std::function< bool()> Job
Definition async.h:34
#define WAIT_TIME
Definition config.h:13
#define HEARTSHARED_EXPORT
Q_DECLARE_METATYPE(QH::HostAddress)
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13