Diana Software
QDbWatchdogThreadHandler.cc
Go to the documentation of this file.
2 
3 #include "QError.hh"
4 #include "QDbWatchdogThread.hh"
5 #include <boost/thread.hpp>
6 
7 //_____________________________________________________________________________
10  fTimer(NULL),
11  fDb(NULL)
12 {
13 }
14 
15 
16 //_____________________________________________________________________________
18 {
19  if(NULL == fTimer)
20  return QError(QERR_UNDEFINED_STATUS, __FILE__, __LINE__,
21  "timer is not set");
22  if(NULL == fDb)
23  return QError(QERR_UNDEFINED_STATUS, __FILE__, __LINE__,
24  "database is not set");
25 
26 
27 
28  QDbWatchdogThread thread;
29  thread.SetError(fErr);
31  thread.SetWatchdogTimer(fTimer);
32  thread.SetDatabase(fDb);
33 
34  fThread = new boost::thread(thread);
35 
36  bool isRunning;
37  QError err = Check(isRunning);
38  if(err != QERR_SUCCESS)
39  return err;
40  if(!isRunning)
41  return QError(QERR_UNDEFINED_STATUS, __FILE__, __LINE__,
42  "Thread failed to start but did not report an error");
43  return QERR_SUCCESS;
44 }
err
Definition: CheckOF.C:114
@ QERR_UNDEFINED_STATUS
Definition: QError.hh:51
@ QERR_SUCCESS
Definition: QError.hh:27
general purpose thread handler class
boost::thread * fThread
QError Check(bool &isRunning)
void SetError(QError *err)
Definition: QBaseThread.hh:25
void SetControlFlag(const int *flag)
Definition: QBaseThread.hh:26
QDb * fDb
not owned by thsi object
QWatchdogTimer * fTimer
not owned by this object
thread responsible for closing the database connection after it remains idle for a certain amount of ...
void SetDatabase(QDb *db)
void SetWatchdogTimer(QWatchdogTimer *timer)
error class with error type and description
Definition: QError.hh:115