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

Diff of /innwebd/thread_pool.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.1 by sysadm, Sat Jul 3 08:38:54 2004 UTC Revision 1.2 by sysadm, Sat Jul 3 09:37:58 2004 UTC
# Line 16  Line 16 
16    
17  #include <time.h>  #include <time.h>
18    
19  #define THREAD_SPOOL_MAX_THREAD 256  #define TS_MAX_THREAD                   256
20  #define THREAD_SPOOL_DEFAULT_TIMEOUT 10000  #define TS_DEFAULT_TIMEOUT              10000
21  #define THREAD_SPOOL_SETLOCK_TMEOUT 100  #define TS_SETLOCK_TIMEOUT              100
22    #define TS_SETLOCK_TIMEOUT_MAX  10000
23    
24  class thread_pool  class thread_pool
25  {  {
# Line 27  public: Line 28  public:
28                  S_UNKNOWN                               =       -1,                  S_UNKNOWN                               =       -1,
29                  S_UNUSED                                =       0,                  S_UNUSED                                =       0,
30                  S_WORKING                               =       1,                  S_WORKING                               =       1,
31                  S_WAITING                               =       2,                  S_WAITING                               =       2
                 S_TERMINATED                    =       3  
32          };          };
33          enum error_code{          enum error_code{
34                  E_NOERROR                               =       0,                  E_NOERROR                               =       0,
35                  E_LOCK_TIMEOUT                  =       1,                  E_LOCK_TIMEOUT                  =       1,
36                  E_MAX_THREAD_EXCEEDED   =       2,                  E_MAX_THREAD_EXCEEDED   =       2,
37                  E_THREAD_NOT_FOUND              =       3                  E_THREAD_NOT_FOUND              =       3,
38                    E_INVALID_TIMEOUT               =       4,
39                    E_KILL_THREAD_FAILED    =       5
40          };          };
41  private:  private:
42          UINT uThreadCount;          UINT uThreadCount;
43          UINT uThreadMax;          UINT uThreadMax;
44          HANDLE hThreadList[THREAD_SPOOL_MAX_THREAD];          HANDLE hThreadList[TS_MAX_THREAD];
45          thread_status uThreadStatusList[THREAD_SPOOL_MAX_THREAD];          thread_status uThreadStatusList[TS_MAX_THREAD];
46          double time_status_keep[THREAD_SPOOL_MAX_THREAD];          clock_t time_status_set[TS_MAX_THREAD];
47          double thread_timeout;          clock_t thread_timeout;
48          bool bProcessLock;          bool bProcessLock;
49          int SetLock(bool bLock, time_t tTimeout = THREAD_SPOOL_SETLOCK_TMEOUT);          int SetLock(bool bLock, clock_t tTimeout = TS_SETLOCK_TIMEOUT);
50          error_code uLastErrorCode;          error_code uLastErrorCode;
51  public:  public:
52          thread_pool(UINT uThreadMax = THREAD_SPOOL_MAX_THREAD, double thread_timeout = THREAD_SPOOL_DEFAULT_TIMEOUT);          thread_pool(UINT uThreadMax = TS_MAX_THREAD, clock_t thread_timeout = TS_DEFAULT_TIMEOUT);
53          ~thread_pool(void);          ~thread_pool(void);
54          UINT GetLastError(void);          int GetLastError(void);
55          int AddThread(HANDLE hThread);          int AddThread(HANDLE hThread);
56          int RemoveThread(HANDLE hThread);          int RemoveThread(HANDLE hThread);
57          int SetThreadStatus(HANDLE hThread, UINT uStatus);          int SetThreadStatus(HANDLE hThread, int uStatus);
58          UINT GetThreadStatus(HANDLE hThread);          int GetThreadStatus(HANDLE hThread);
59            int KillDeadThread(void);
60  };  };


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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