blob: 9adf1b90a358b021cc0b31aadfba063c42f45758 [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001#ifndef CCXX_PRIVATE_H_
2#define CCXX_PRIVATE_H_
3
4#ifdef CCXX_NAMESPACES
5namespace ost {
6#endif
7
8class ThreadImpl
9{
10friend class Thread;
11friend class DummyThread;
12friend class PosixThread;
13friend class Slog;
14
15 ThreadImpl(int type):
16 _msgpos(0),
17 _throw(Thread::throwObject),
18 _tid(0),
19 _suspendEnable(true),
20 _type(type),
21#ifndef WIN32
22 _jtid(0)
23#else
24 _detached(false),
25 _active(false),
26 _hThread(NULL),
27 _cancellation(NULL)
28#endif
29 { ; };
30
31 // derived class copy constructor creates new instance, so base
32 // copy constructor of ThreadImpl should do nothing...
33
34 ThreadImpl(const ThreadImpl& copy)
35 {;};
36
37 ThreadImpl &operator=(const ThreadImpl& copy)
38 {return *this;};
39
40#ifdef _THR_MACH
41 mach_port_t _mach;
42#endif
43
44#ifndef WIN32
45 pthread_attr_t _attr;
46 AtomicCounter _suspendcount;
47 static ThreadKey _self;
48#else
49 size_t _stack;
50 int _priority;
51 HANDLE _cancellation;
52#endif
53 // log information
54 size_t _msgpos;
55 char _msgbuf[128];
56 Thread::Throw _throw;
57 cctid_t _tid;
58
59#ifndef WIN32
60 friend Thread *getThread(void);
61 volatile bool _suspendEnable:1;
62 unsigned int _type:3;
63 cctid_t _jtid;
64#else
65 bool _detached:1;
66 bool _active:1;
67 bool _suspendEnable:1;
68 unsigned int _type:3;
69 static unsigned __stdcall Execute(Thread *th);
70 HANDLE _hThread;
71#endif
72
73public:
74 // C binding functions
75 static inline void ThreadExecHandler(Thread* th);
76#ifndef WIN32
77 static inline RETSIGTYPE ThreadSigSuspend(int);
78 static inline void ThreadCleanup(Thread* arg);
79 static inline void ThreadDestructor(Thread* arg);
80 static inline void PosixThreadSigHandler(int signo);
81#endif
82};
83
84#ifdef CCXX_NAMESPACES
85}
86#endif
87
88#endif