正在显示
1 个修改的文件
包含
67 行增加
和
0 行删除
src/server/spserver/spiocplfserver.hpp
0 → 100644
1 | +/* | |
2 | + * Copyright 2008 Stephen Liu | |
3 | + * For license terms, see the file COPYING along with this library. | |
4 | + */ | |
5 | + | |
6 | +#ifndef __splfserver_hpp__ | |
7 | +#define __splfserver_hpp__ | |
8 | + | |
9 | +#include "spthread.hpp" | |
10 | + | |
11 | +class SP_IocpEventArg; | |
12 | +class SP_ThreadPool; | |
13 | +class SP_HandlerFactory; | |
14 | +class SP_CompletionHandler; | |
15 | +class SP_IOChannelFactory; | |
16 | + | |
17 | +typedef struct tagSP_IocpAcceptArg SP_IocpAcceptArg_t; | |
18 | + | |
19 | +// leader/follower thread pool server | |
20 | +class SP_IocpLFServer { | |
21 | +public: | |
22 | + SP_IocpLFServer( const char * bindIP, int port, SP_HandlerFactory * handlerFactory ); | |
23 | + ~SP_IocpLFServer(); | |
24 | + | |
25 | + void setTimeout( int timeout ); | |
26 | + void setMaxConnections( int maxConnections ); | |
27 | + void setMaxThreads( int maxThreads ); | |
28 | + void setReqQueueSize( int reqQueueSize, const char * refusedMsg ); | |
29 | + void setIOChannelFactory( SP_IOChannelFactory * ioChannelFactory ); | |
30 | + | |
31 | + void shutdown(); | |
32 | + int isRunning(); | |
33 | + | |
34 | + // return -1 : cannot listen on ip:port, 0 : ok | |
35 | + int run(); | |
36 | + | |
37 | + void runForever(); | |
38 | + | |
39 | +private: | |
40 | + HANDLE mCompletionPort; | |
41 | + char mBindIP[ 64 ]; | |
42 | + int mPort; | |
43 | + int mIsShutdown; | |
44 | + int mIsRunning; | |
45 | + | |
46 | + SP_IocpAcceptArg_t * mAcceptArg; | |
47 | + | |
48 | + SP_IocpEventArg * mEventArg; | |
49 | + | |
50 | + int mMaxThreads; | |
51 | + SP_ThreadPool * mThreadPool; | |
52 | + | |
53 | + SP_CompletionHandler * mCompletionHandler; | |
54 | + | |
55 | + sp_thread_mutex_t mMutex; | |
56 | + | |
57 | + void handleOneEvent(); | |
58 | + | |
59 | + static void lfHandler( void * arg ); | |
60 | + | |
61 | + static void sigHandler( int, short, void * arg ); | |
62 | + | |
63 | + static sp_thread_result_t SP_THREAD_CALL acceptThread( void * arg ); | |
64 | +}; | |
65 | + | |
66 | +#endif | |
67 | + | ... | ... |
请
注册
或
登录
后发表评论