Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
CustomThread.h
1// CustomThread.h: interface for the CCustomThread class.
2//
3//////////////////////////////////////////////////////////////////////
4
5#if !defined(AFX_CUSTOMTHREAD_H__717C0FE3_DFA5_4C22_A6FE_56A15B3434C8__INCLUDED_)
6#define AFX_CUSTOMTHREAD_H__717C0FE3_DFA5_4C22_A6FE_56A15B3434C8__INCLUDED_
7
8#ifdef _MSC_VER
9#pragma once
10#endif // _MSC_VER
11
12#include "XThread.h"
13
14BEGIN_MOOTOOLS_NAMESPACE
15
16typedef enum _THREAD_STATE_INFO
17{
18 THREAD_STOP = 0x00, // Thread is finished (set in the created thread)
19 THREAD_RUN_STATE_FLAGS = 0x0F,
20 THREAD_INIT = 0x02, // Thread is being initialized (set in the thread which create the thread)
21 THREAD_RUN = 0x04, // Thread is running (set in the created thread)
22 THREAD_PAUSE = 0x08, // Thread as stop
23 THREAD_ASK_FOR_CANCEL = 0x100, // Ask the thread to cancel (set in the thread which create the thread)
25
26#define THREAD_INIT_STATE(a) (a)
27#define GET_THREAD_RUN_STATE(a) (a & THREAD_RUN_STATE_FLAGS)
28#define SET_THREAD_RUN_STATE(a, b) ((a & ~THREAD_RUN_STATE_FLAGS) | b)
29#define SET_CANCEL_THREAD_FLAG(a) (a | THREAD_ASK_FOR_CANCEL)
30#define CLEAR_CANCEL_THREAD_FLAG(a) (a & ~THREAD_ASK_FOR_CANCEL)
31#define GET_CANCEL_THREAD_FLAG(a) (a & THREAD_ASK_FOR_CANCEL)
32
33class DLL_TOOLSFUNCTION CCustomThread : public CXThread
34{
35 DECLARE_DYNAMIC_XOBJECT(CCustomThread)
36
37protected:
38 bool quit;
39 static bool stopThreads;
40
41public:
43 CCustomThread(XTHREADPROC threadCallback, void* threadData);
44 virtual ~CCustomThread();
45
46 void SetThreadName(const char *name);
47 static void SetThreadName(xThreadID threadID, const char *name);
48 static void SetCurrentThreadName(const char *name);
49 static xThreadID GetCurrentThreadID();
50 static unsigned int GetRunningThreadCount();
51 static bool HardThreadsTermination(bool onlyNotCriticalThreads = false); // return true if one thread has been killed, false otherwise
52 static void WaitEndOfThreads(bool exitApplication = true);
53 static void AskForThreadsEnd(bool resumeThreads);
54 static bool ThreadsMustTerminate();
55 void StopThread();
56 bool MustTerminate();
57};
58
59END_MOOTOOLS_NAMESPACE
60
61#endif // !defined(AFX_CUSTOMTHREAD_H__717C0FE3_DFA5_4C22_A6FE_56A15B3434C8__INCLUDED_)
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27
Definition CustomThread.h:34
Definition XThread.h:14