Heart 1.3.842.34c2ab5
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-2024 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 "atomicmetatypes.h"
14#include "heart_global.h"
15
16namespace QH {
17
26class HEARTSHARED_EXPORT Async: public QObject {
27
28 Q_OBJECT
29
30public:
35 using Job = std::function<bool()>;
36
45 bool asyncLauncher(const Job &job, bool await = false, bool freaze = true) const;
46
47protected:
54 Async(QThread* thread, QObject* ptr = nullptr);
55
60 ~Async();
61
69 bool waitFor(bool* condition, int timeout = WAIT_TIME, bool freaze = true) const;
70
78 bool waitFor(const Job &condition, int timeout = WAIT_TIME, bool freaze = true) const;
79
80private slots:
81
137 void asyncHandler (QH::Async::Job job,
138 bool* endOfWork = nullptr,
139 bool* resultOfWork = nullptr) const;
140
141
142private:
149 void threadAnalize(QThread* thread);
150};
151
152}
153
155#endif // ASYNC_H
The Async class This is bundle of async templates and async wrappers.
Definition async.h:26
std::function< bool()> Job
Definition async.h:35
#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