Torc
0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
torc
torcqthread.cpp
Go to the documentation of this file.
1
/* Class TorcQThread
2
*
3
* Copyright (C) Mark Kendall 2013-18
4
*
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
*
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
14
*
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18
*/
19
20
// Torc
21
#include "
torclocalcontext.h
"
22
#include "
torcloggingimp.cpp
"
23
#include "
torcqthread.h
"
24
43
static
QThread *
gMainThread
=
nullptr
;
44
45
void
TorcQThread::SetMainThread
(
void
)
46
{
47
gMainThread
= QThread::currentThread();
48
InitRand
();
49
QThread::currentThread()->setObjectName(QStringLiteral(
"MainLoop"
));
50
}
51
52
bool
TorcQThread::IsMainThread
(
void
)
53
{
54
if
(
gMainThread
)
55
return
QThread::currentThread() ==
gMainThread
;
56
return
QThread::currentThread()->objectName() ==
TORC_MAIN_THREAD
;
57
}
58
59
void
TorcQThread::InitRand
(
void
)
60
{
61
qsrand(QDateTime::currentDateTimeUtc().toTime_t() ^ QTime::currentTime().msec());
62
}
63
64
TorcQThread::TorcQThread
(
const
QString &Name)
65
: QThread()
66
{
67
// this ensures database access is allowed if needed
68
setObjectName(Name);
69
}
70
71
void
TorcQThread::run
(
void
)
72
{
73
Initialise
();
74
QThread::run();
75
Deinitialise
();
76
}
77
79
void
TorcQThread::Initialise
(
void
)
80
{
81
RegisterLoggingThread
();
82
InitRand
();
83
84
Start
();
85
86
emit
Started
();
87
}
88
90
void
TorcQThread::Deinitialise
(
void
)
91
{
92
Finish
();
93
94
emit
Finished
();
95
96
// ensure database connections are released
97
gLocalContext
->
CloseDatabaseConnections
();
98
DeregisterLoggingThread
();
99
}
TorcQThread::IsMainThread
static bool IsMainThread(void)
Definition:
torcqthread.cpp:52
torcloggingimp.cpp
TorcQThread::Initialise
void Initialise(void)
Performs Torc specific thread initialisation.
Definition:
torcqthread.cpp:79
gLocalContext
TorcLocalContext * gLocalContext
Definition:
torclocalcontext.cpp:48
TorcQThread::run
virtual void run(void)
Definition:
torcqthread.cpp:71
TorcQThread::Finish
virtual void Finish(void)=0
gMainThread
static QThread * gMainThread
Definition:
torcqthread.cpp:43
TorcQThread::TorcQThread
TorcQThread(const QString &Name)
Definition:
torcqthread.cpp:64
TorcQThread::Finished
void Finished(void)
TorcQThread::SetMainThread
static void SetMainThread(void)
Definition:
torcqthread.cpp:45
TorcLocalContext::CloseDatabaseConnections
void CloseDatabaseConnections(void)
Definition:
torclocalcontext.cpp:319
RegisterLoggingThread
void RegisterLoggingThread(void)
Definition:
torcloggingimp.cpp:728
TorcQThread::Deinitialise
void Deinitialise(void)
Performs Torc specific thread cleanup.
Definition:
torcqthread.cpp:90
TorcQThread::InitRand
static void InitRand(void)
Definition:
torcqthread.cpp:59
TORC_MAIN_THREAD
#define TORC_MAIN_THREAD
Definition:
torclocaldefs.h:10
TorcQThread::Start
virtual void Start(void)=0
TorcQThread::Started
void Started(void)
torclocalcontext.h
DeregisterLoggingThread
void DeregisterLoggingThread(void)
Definition:
torcloggingimp.cpp:744
torcqthread.h
Generated on Sat Jan 5 2019 21:54:03 for Torc by
1.8.11