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

Annotation of /innwebd/thread_pool.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Sat Jul 3 08:38:54 2004 UTC (21 years, 8 months ago) by sysadm
Branch: MAIN
Content type: text/x-chdr
no message

1 sysadm 1.1 /*******************************************************/
2     /* */
3     /* LeafOK Innd */
4     /* Copyright (C) LeafOK.com, 2003-2004 */
5     /* */
6     /* Programmed by Leaf */
7     /* E-mail:leaf@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 THREAD_SPOOL_MAX_THREAD 256
20     #define THREAD_SPOOL_DEFAULT_TIMEOUT 10000
21     #define THREAD_SPOOL_SETLOCK_TMEOUT 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     S_TERMINATED = 3
32     };
33     enum error_code{
34     E_NOERROR = 0,
35     E_LOCK_TIMEOUT = 1,
36     E_MAX_THREAD_EXCEEDED = 2,
37     E_THREAD_NOT_FOUND = 3
38     };
39     private:
40     UINT uThreadCount;
41     UINT uThreadMax;
42     HANDLE hThreadList[THREAD_SPOOL_MAX_THREAD];
43     thread_status uThreadStatusList[THREAD_SPOOL_MAX_THREAD];
44     double time_status_keep[THREAD_SPOOL_MAX_THREAD];
45     double thread_timeout;
46     bool bProcessLock;
47     int SetLock(bool bLock, time_t tTimeout = THREAD_SPOOL_SETLOCK_TMEOUT);
48     error_code uLastErrorCode;
49     public:
50     thread_pool(UINT uThreadMax = THREAD_SPOOL_MAX_THREAD, double thread_timeout = THREAD_SPOOL_DEFAULT_TIMEOUT);
51     ~thread_pool(void);
52     UINT GetLastError(void);
53     int AddThread(HANDLE hThread);
54     int RemoveThread(HANDLE hThread);
55     int SetThreadStatus(HANDLE hThread, UINT uStatus);
56     UINT GetThreadStatus(HANDLE hThread);
57     };

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