-
Notifications
You must be signed in to change notification settings - Fork 3
/
ORHandlerThread.hh
47 lines (39 loc) · 1.27 KB
/
ORHandlerThread.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// ORHandlerThread.hh
#ifndef _ORHandlerThread_hh
#define _ORHandlerThread_hh
/* This class handles all the signals and signal passing to
ORVSignaHandlers. It MUST BE called from the main thread before
any other threads are started. This is because it sets to block
SIGINT, and every derived thread inherits this signal block.
It is easiest just to call this before any other OR object.
The proper call to make is like:
ORHandlerThread handler;
handler.StartThread()
StopThread() does not need to be called, nor does it really work
as advertised due to some inconsistencies between Mac os x, posix,
linux standards etc. Therefore, if you don't want a signal handling
thread, then don't instantiate this class.
*/
#ifndef __CINT__
#include <pthread.h>
#include <signal.h>
#include "ORReadWriteLock.hh"
class ORHandlerThread
{
public:
ORHandlerThread();
~ORHandlerThread();
void StartThread();
void StopThread();
protected:
static void* SigWaitThread(void*);
bool fThreadIsRunning;
bool fCanIStart;
pthread_t fThread;
pthread_attr_t fAttr;
static ORReadWriteLock fRWLock;
static ORHandlerThread* fHandlerThread;
static sigset_t fSigsToBlock;
};
#endif /* __CINT__ */
#endif /* _ORHandlerThread_hh */