/[LeafOK_CVS]/innwebd/thread_pool.h
ViewVC logotype

Contents of /innwebd/thread_pool.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations)
Sat Feb 26 16:10:26 2005 UTC (21 years ago) by sysadm
Branch: MAIN
CVS Tags: innwebd_1-4-16-0_MIL
Changes since 1.5: +1 -1 lines
Content type: text/x-chdr
Copyright update

1 /*******************************************************/
2 /* */
3 /* LeafOK Innbbsd */
4 /* Copyright (C) LeafOK.com, 2003-2005 */
5 /* */
6 /* Programmed by Leaf */
7 /* E-mail:leaflet@leafok.com QQ:6049044 */
8 /* */
9 /* http://bbs.leafok.com */
10 /* http://bbs.leafok.net */
11 /* http://bbs.fenglin.info */
12 /* */
13 /*******************************************************/
14
15 #pragma once
16
17 #include <time.h>
18
19 #define TS_MAX_THREAD 256
20 #define TS_DEFAULT_TIMEOUT 10000
21 #define TS_SETLOCK_TIMEOUT 100
22
23 class thread_pool
24 {
25 public:
26 enum thread_status{
27 S_UNKNOWN = -1,
28 S_UNUSED = 0,
29 S_WORKING = 1,
30 S_WAITING = 2
31 };
32 enum error_code{
33 E_NOERROR = 0,
34 E_LOCK_TIMEOUT = 1,
35 E_MAX_THREAD_EXCEEDED = 2,
36 E_THREAD_NOT_FOUND = 3,
37 E_INVALID_TIMEOUT = 4,
38 E_KILL_THREAD_FAILED = 5,
39 E_KILLER_BEGIN_FAILED = 6,
40 E_KILLER_END_FAILED = 7,
41 E_INVALID_THREAD = 8
42 };
43 private:
44 UINT uThreadCount;
45 UINT uThreadMax;
46 ULONG ulThreadIdList[TS_MAX_THREAD];
47 thread_status uThreadStatusList[TS_MAX_THREAD];
48 clock_t time_status_set[TS_MAX_THREAD];
49 clock_t thread_timeout[TS_MAX_THREAD];
50 bool bProcessLock;
51 int SetLock(bool bLock, clock_t tTimeout = TS_SETLOCK_TIMEOUT);
52 error_code uLastErrorCode;
53 ULONG ulThreadKillerId;
54 bool bTerminateThreadKiller;
55 public:
56 thread_pool(UINT uThreadMax = TS_MAX_THREAD);
57 ~thread_pool(void);
58 static DWORD KillDeadThread(LPVOID pParam);
59 int GetLastError(void) const;
60 int AddThread(ULONG ulThreadId, clock_t thread_timeout = TS_DEFAULT_TIMEOUT);
61 int RemoveThread(ULONG ulThreadId);
62 int SetThreadStatus(ULONG ulThreadId, int uStatus);
63 int GetThreadStatus(ULONG ulThreadId);
64 int GetThreadCount(void) const;
65 int EnableKillDeadThread(void);
66 int DisableKillDeadThread(void);
67 int KillAllThread(void);
68 };

webmaster@leafok.com
ViewVC Help
Powered by ViewVC 1.3.0-beta1