cutelyst
3.7.0
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
Cutelyst
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
#include "context.h"
7
8
#include <QPointer>
9
#include <QLoggingCategory>
10
11
Q_LOGGING_CATEGORY(CUTELYST_ASYNC,
"cutelyst.async"
, QtInfoMsg)
12
13
using namespace
Cutelyst
;
14
15
namespace
Cutelyst
{
16
17
class
ASyncPrivate
{
18
public
:
19
ASyncPrivate
(
Context
*_c) : c(_c) {
20
// qDebug(CUTELYST_ASYNC, "Detaching async %s", qPrintable(c->objectName()));
21
c->detachAsync();
22
}
23
ASyncPrivate
(
Context
*_c, std::function<
void
(
Context
*c)> _cb) : c(_c), cb(_cb) {
24
// qDebug(CUTELYST_ASYNC, "Detaching async %s", qPrintable(c->objectName()));
25
c->
detachAsync
();
26
}
27
~
ASyncPrivate
() {
28
if
(!c.isNull()) {
29
if
(cb) {
30
cb(c);
31
}
32
// qDebug(CUTELYST_ASYNC, "Attaching async %s", qPrintable(c->objectName()));
33
c->
attachAsync
();
34
}
35
}
36
37
QPointer<Context> c;
38
std::function<void(
Context
*c)> cb;
39
};
40
41
}
42
43
ASync::ASync() =
default
;
44
55
ASync::ASync(
Context
*c) : d(std::make_shared<
ASyncPrivate
>(c))
56
{
57
}
58
71
ASync::ASync(
Context
*c, std::function<
void
(
Context
*)> cb) : d(std::make_shared<
ASyncPrivate
>(c, cb))
72
{
73
}
74
78
ASync::ASync(
const
ASync
&other) : d(other.d)
79
{
80
}
81
85
ASync::ASync(
ASync
&&other) noexcept
86
: d(std::move(other.d))
87
{
88
}
89
90
ASync::~ASync() =
default
;
91
92
ASync
&ASync::operator =(
const
ASync
©)
93
{
94
d = copy.d;
95
return
*
this
;
96
}
Cutelyst::ASyncPrivate
Definition:
async.cpp:17
Cutelyst::ASync
Definition:
async.h:18
Cutelyst::Context
The Cutelyst Context.
Definition:
context.h:39
Cutelyst::Context::attachAsync
void attachAsync()
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:
Mainpage.dox:8
Generated by
1.9.1