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 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
#ifdef CCXX_NAMESPACES
namespace ost {
#endif
class ThreadImpl
{
friend class Thread;
friend class DummyThread;
friend class PosixThread;
friend class Slog;
friend CCXX_EXPORT(Thread::Throw) getException(void);
friend CCXX_EXPORT(void) setException(Thread::Throw mode);
ThreadImpl(int type):
_msgpos(0),
_throw(Thread::throwObject),
_suspendEnable(true),
_type(type),
_tid(0)
#ifndef WIN32
#else
,
_active(false),
_hThread(NULL),
_cancellation(NULL)
#endif
{ ; };
// derived class copy constructor creates new instance, so base
// copy constructor of ThreadImpl should do nothing...
ThreadImpl(const ThreadImpl& copy)
{;};
ThreadImpl &operator=(const ThreadImpl& copy)
{return *this;};
#ifndef WIN32
pthread_attr_t _attr;
AtomicCounter _suspendcount;
static ThreadKey _self;
#else
HANDLE _cancellation;
#endif
// log information
int _msgpos;
char _msgbuf[128];
enum Thread::Throw _throw;
#ifndef WIN32
friend Thread *getThread(void);
volatile bool _suspendEnable:1;
unsigned int _type:3;
#else
bool _active:1;
bool _suspendEnable:1;
unsigned int _type:3;
static unsigned __stdcall Execute(Thread *th);
HANDLE _hThread;
#endif
cctid_t _tid;
public:
// C binding functions
static inline void ThreadExecHandler(Thread* th);
#ifndef WIN32
static inline RETSIGTYPE ThreadSigSuspend(int);
static inline void ThreadCleanup(Thread* arg);
static inline void ThreadDestructor(Thread* arg);
static inline void PosixThreadSigHandler(int signo);
#endif
};
#ifdef CCXX_NAMESPACES
}
#endif
|