cutelyst
3.9.1
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"
, QtInfoMsg)
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
51
ASync::ASync() =
default
;
52
63
ASync::ASync(
Context
*c)
64
: d(std::make_shared<
ASyncPrivate
>(c))
65
{
66
}
67
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
101
ASync::~ASync() =
default
;
102
103
ASync
&ASync::operator=(
const
ASync
©)
104
{
105
d = copy.d;
106
return
*
this
;
107
}
Cutelyst::ASyncPrivate
Definition
async.cpp:19
Cutelyst::ASync
Definition
async.h:17
Cutelyst::Context
The Cutelyst Context.
Definition
context.h:39
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition
Mainpage.dox:8
QPointer
Cutelyst
async.cpp
Generated on
for cutelyst by
1.16.1