Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
async.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2027 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:
54 Async(QThread* thread = 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
std::function< bool()> Job
Definition async.h:34
Async(QThread *thread=nullptr)
Async This is default constructor of the async object.
Definition async.cpp:38
bool waitFor(bool *condition, int timeout=WAIT_TIME, bool freaze=true) const
waitFor This is base wait function.
Definition async.cpp:70
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
#define WAIT_TIME
Definition config.h:13
Q_DECLARE_METATYPE(QH::HostAddress)
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13