Diana Software
pkg
dbbase
QDbWatchdogThread.cc
Go to the documentation of this file.
1
#include "
QDbWatchdogThread.hh
"
2
3
#include "
QError.hh
"
4
#include "
QDb.hh
"
5
#include "
QWatchdogTimer.hh
"
6
#include <unistd.h>
7
8
//_____________________________________________________________________________
9
QDbWatchdogThread::QDbWatchdogThread
():
10
QBaseThread
()
11
{
12
}
13
14
15
void
QDbWatchdogThread::operator()
()
16
{
17
if
(NULL ==
fErr
)
18
throw
QError
(
QERR_UNDEFINED_STATUS
, __FILE__, __LINE__,
19
"fErr is not set for this thread"
);
20
21
if
(NULL ==
fControlFlag
)
22
{
23
fErr
->
Set
(
QERR_UNDEFINED_STATUS
, __FILE__, __LINE__,
24
"fControlFlag is not set for this thread"
);
25
return
;
26
}
27
28
if
(NULL ==
fTimer
)
29
{
30
fErr
->
Set
(
QERR_UNDEFINED_STATUS
, __FILE__, __LINE__,
31
"fTimer is not set for this thread"
);
32
return
;
33
}
34
35
if
(NULL ==
fDb
)
36
{
37
fErr
->
Set
(
QERR_UNDEFINED_STATUS
, __FILE__, __LINE__,
38
"fDb is not set for this thread"
);
39
return
;
40
}
41
42
43
while
(0 == *
fControlFlag
) {
44
if
(*
fErr
!=
QERR_SUCCESS
)
45
return
;
46
47
bool
elapsed =
false
;
48
*
fErr
=
fTimer
->
TimeoutElapsed
(elapsed);
49
if
(*
fErr
!=
QERR_SUCCESS
)
50
return
;
51
52
if
(elapsed &&
fDb
->
IsConnected
())
53
{
54
bool
success
=
fDb
->
Disconnect
();
55
if
(!
success
) {
56
fErr
->
Set
(
QERR_UNDEFINED_STATUS
, __FILE__, __LINE__,
57
"Disconnect failed()"
);
58
return
;
59
}
60
}
61
usleep(500000);
62
}
63
return
;
64
}
success
success
Definition:
CheckOF.C:112
QDbWatchdogThread.hh
QDb.hh
QError.hh
QERR_UNDEFINED_STATUS
@ QERR_UNDEFINED_STATUS
Definition:
QError.hh:51
QERR_SUCCESS
@ QERR_SUCCESS
Definition:
QError.hh:27
QWatchdogTimer.hh
QBaseThread
base abstract class for running a separate thread
Definition:
QBaseThread.hh:21
QBaseThread::fControlFlag
const int * fControlFlag
Definition:
QBaseThread.hh:32
QBaseThread::fErr
QError * fErr
Definition:
QBaseThread.hh:31
QDbWatchdogThread::fTimer
QWatchdogTimer * fTimer
Definition:
QDbWatchdogThread.hh:37
QDbWatchdogThread::fDb
QDb * fDb
Definition:
QDbWatchdogThread.hh:38
QDbWatchdogThread::operator()
virtual void operator()()
Definition:
QDbWatchdogThread.cc:15
QDbWatchdogThread::QDbWatchdogThread
QDbWatchdogThread()
Definition:
QDbWatchdogThread.cc:9
QDb::Disconnect
bool Disconnect()
Definition:
QDb.cc:151
QDb::IsConnected
bool IsConnected() const
Definition:
QDb.cc:66
QError
error class with error type and description
Definition:
QError.hh:115
QError::Set
void Set(QError_ e=QERR_SUCCESS, const std::string &descr="")
set to error code and description (default is SUCCESS)
Definition:
QError.cc:157
QWatchdogTimer::TimeoutElapsed
QError TimeoutElapsed(bool &elapsed) const
Definition:
QWatchdogTimer.cc:43
Generated by
1.9.1