| 19 |
#define TS_MAX_THREAD 256 |
#define TS_MAX_THREAD 256 |
| 20 |
#define TS_DEFAULT_TIMEOUT 10000 |
#define TS_DEFAULT_TIMEOUT 10000 |
| 21 |
#define TS_SETLOCK_TIMEOUT 100 |
#define TS_SETLOCK_TIMEOUT 100 |
|
#define TS_SETLOCK_TIMEOUT_MAX 10000 |
|
| 22 |
|
|
| 23 |
class thread_pool |
class thread_pool |
| 24 |
{ |
{ |
| 43 |
HANDLE hThreadList[TS_MAX_THREAD]; |
HANDLE hThreadList[TS_MAX_THREAD]; |
| 44 |
thread_status uThreadStatusList[TS_MAX_THREAD]; |
thread_status uThreadStatusList[TS_MAX_THREAD]; |
| 45 |
clock_t time_status_set[TS_MAX_THREAD]; |
clock_t time_status_set[TS_MAX_THREAD]; |
| 46 |
clock_t thread_timeout; |
clock_t thread_timeout[TS_MAX_THREAD]; |
| 47 |
bool bProcessLock; |
bool bProcessLock; |
| 48 |
int SetLock(bool bLock, clock_t tTimeout = TS_SETLOCK_TIMEOUT); |
int SetLock(bool bLock, clock_t tTimeout = TS_SETLOCK_TIMEOUT); |
| 49 |
error_code uLastErrorCode; |
error_code uLastErrorCode; |
| 50 |
|
HANDLE hThreadKiller; |
| 51 |
public: |
public: |
| 52 |
thread_pool(UINT uThreadMax = TS_MAX_THREAD, clock_t thread_timeout = TS_DEFAULT_TIMEOUT); |
thread_pool(UINT uThreadMax = TS_MAX_THREAD); |
| 53 |
~thread_pool(void); |
~thread_pool(void); |
| 54 |
int GetLastError(void); |
static DWORD KillDeadThread(LPVOID pParam); |
| 55 |
int AddThread(HANDLE hThread); |
int GetLastError(void) const; |
| 56 |
|
int AddThread(HANDLE hThread, clock_t thread_timeout = TS_DEFAULT_TIMEOUT); |
| 57 |
int RemoveThread(HANDLE hThread); |
int RemoveThread(HANDLE hThread); |
| 58 |
int SetThreadStatus(HANDLE hThread, int uStatus); |
int SetThreadStatus(HANDLE hThread, int uStatus); |
| 59 |
int GetThreadStatus(HANDLE hThread); |
int GetThreadStatus(HANDLE hThread); |
| 60 |
int KillDeadThread(void); |
int GetThreadCount(void) const; |
| 61 |
|
int EnableKillDeadThread(void); |
| 62 |
|
int DisableKillDeadThread(void); |
| 63 |
}; |
}; |