-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathOSThread.c
69 lines (59 loc) · 2.05 KB
/
OSThread.c
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
/***************************************************************************************************************:')
OSThread.h
Threads handling.
Fabrice Le Bars
Created : 2007
***************************************************************************************************************:)*/
// Prevent Visual Studio Intellisense from defining _WIN32 and _MSC_VER when we use
// Visual Studio to edit Linux or Borland C++ code.
#ifdef __linux__
# undef _WIN32
#endif // __linux__
#if defined(__GNUC__) || defined(__BORLANDC__)
# undef _MSC_VER
#endif // defined(__GNUC__) || defined(__BORLANDC__)
#include "OSThread.h"
#ifndef _WIN32
//// Portable programs should use sched_get_priority_min and sched_get_priority_max to
//// find the range of priorities supported for a particular policy.
//int THREAD_PRIORITY_TIME_CRITICAL = 99;
//int THREAD_PRIORITY_HIGHEST = 70;
//int THREAD_PRIORITY_ABOVE_NORMAL = 60;
//int THREAD_PRIORITY_NORMAL = 50;
//int THREAD_PRIORITY_BELOW_NORMAL = 40;
//int THREAD_PRIORITY_LOWEST = 1;
//int THREAD_PRIORITY_IDLE = 0;
#endif // !_WIN32
#ifdef ENABLE_CANCEL_THREAD
#ifdef _WIN32
VOID CALLBACK _CancelThreadAPC(ULONG_PTR dwParam)
{
//TerminateThread((HANDLE)dwParam, EXIT_CANCELED_THREAD);
//CloseHandle((HANDLE)dwParam);
UNREFERENCED_PARAMETER(dwParam);
#ifdef USE_CREATE_THREAD
ExitThread(EXIT_CANCELED_THREAD);
#else
_endthreadex(EXIT_CANCELED_THREAD);
#endif // USE_CREATE_THREAD
}
#endif // _WIN32
#endif // ENABLE_CANCEL_THREAD
//THREAD_PROC_RETURN_VALUE _ThreadFunction(void* pParam)
//{
// DWORD ThreadResult = NULL;
// THREADPARAM* pThreadParam = (THREADPARAM*)pParam;
//
// // Specific functions that must be called from the thread.
//
// // When initially created, a thread is synchronously cancelable.
// // Here enable the current thread to be canceled (killed) asynchronously (i.e. immediately).
// pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
// pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
//
// ThreadResult = pThreadParam.ThreadFunction(pThreadParam);
//
// //free(pThreadParam);
//
// return ThreadResult;
//}