cutelyst
4.3.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
async.cpp
1
/*
2
* SPDX-FileCopyrightText: (C) 2020-2022 Daniel Nicoletti <dantti12@gmail.com>
3
* SPDX-License-Identifier: BSD-3-Clause
4
*/
5
#include "async.h"
6
7
#include "context.h"
8
9
#include <QLoggingCategory>
10
#include <QPointer>
11
12
Q_LOGGING_CATEGORY(CUTELYST_ASYNC,
"cutelyst.async"
, QtWarningMsg)
13
14
using namespace
Cutelyst
;
15
16
namespace
Cutelyst
{
17
18
class
ASyncPrivate
19
{
20
public
:
21
ASyncPrivate
(
Context
*_c)
22
: c(_c)
23
{
24
// qDebug(CUTELYST_ASYNC, "Detaching async %s", qPrintable(c->objectName()));
25
c->detachAsync();
26
}
27
ASyncPrivate
(
Context
*_c, std::function<
void
(
Context
*c)> _cb)
28
: c(_c)
29
, cb(_cb)
30
{
31
// qDebug(CUTELYST_ASYNC, "Detaching async %s", qPrintable(c->objectName()));
32
c->
detachAsync
();
33
}
34
~ASyncPrivate
()
35
{
36
if
(!c.isNull()) {
37
if
(cb) {
38
cb(c);
39
}
40
// qDebug(CUTELYST_ASYNC, "Attaching async %s", qPrintable(c->objectName()));
41
c->
attachAsync
();
42
}
43
}
44
45
QPointer<Context>
c;
46
std::function<void(
Context
*c)> cb;
47
};
48
49
}
// namespace Cutelyst
50
64
ASync::ASync
() noexcept = default;
65
75
ASync
::
ASync
(
Context
*c)
76
: d(std::make_shared<
ASyncPrivate
>(c))
77
{
78
}
79
80
ASync::ASync
(
Context
*c, std::function<
void
(
Context
*)> cb)
81
: d(std::make_shared<
ASyncPrivate
>(c, cb))
82
{
83
}
84
88
ASync::ASync
(
const
ASync
&other)
89
: d(other.d)
90
{
91
}
92
96
ASync::ASync
(
ASync
&&other) noexcept
97
: d(std::move(other.d))
98
{
99
}
100
104
ASync::~ASync
() =
default
;
105
109
ASync
&
ASync::operator=
(
const
ASync
©)
110
{
111
d = copy.d;
112
return
*
this
;
113
}
Cutelyst::ASyncPrivate
Definition
async.cpp:19
Cutelyst::ASync
Helper class for asynchronous processing.
Definition
async.h:16
Cutelyst::ASync::~ASync
~ASync()
Cutelyst::ASync::operator=
ASync & operator=(const ASync ©)
Definition
async.cpp:109
Cutelyst::ASync::ASync
ASync() noexcept
Cutelyst::Context
The Cutelyst Context.
Definition
context.h:42
Cutelyst::Context::attachAsync
void attachAsync()
Definition
context.cpp:355
Cutelyst::Context::detachAsync
void detachAsync() noexcept
Definition
context.cpp:349
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition
group-core-actions.dox:1
QPointer
Cutelyst
async.cpp
Generated by
1.9.8