提交 a91c569f8626175570d693e7803ec28be1161f6e

作者 LJH 李佳桓
1 个父辈 b8f7da1d

add

正在显示 1 个修改的文件 包含 62 行增加0 行删除
  1 +/*
  2 + * Copyright 2007 Stephen Liu
  3 + * For license terms, see the file COPYING along with this library.
  4 + */
  5 +
  6 +
  7 +#ifndef __spserver_hpp__
  8 +#define __spserver_hpp__
  9 +
  10 +#include <sys/types.h>
  11 +#include "spthread.hpp"
  12 +
  13 +class SP_HandlerFactory;
  14 +class SP_Session;
  15 +class SP_Executor;
  16 +class SP_IOChannelFactory;
  17 +
  18 +struct event;
  19 +
  20 +// half-sync/half-async thread pool server
  21 +class SP_Server {
  22 +public:
  23 + SP_Server( const char * bindIP, int port, SP_HandlerFactory * handlerFactory );
  24 + ~SP_Server();
  25 +
  26 + void setTimeout( int timeout );
  27 + void setMaxConnections( int maxConnections );
  28 + void setMaxThreads( int maxThreads );
  29 + void setReqQueueSize( int reqQueueSize, const char * refusedMsg );
  30 + void setIOChannelFactory( SP_IOChannelFactory * ioChannelFactory );
  31 +
  32 + void shutdown();
  33 + int isRunning();
  34 + int run();
  35 + void runForever();
  36 +
  37 +private:
  38 + SP_HandlerFactory * mHandlerFactory;
  39 + SP_IOChannelFactory * mIOChannelFactory;
  40 +
  41 + char mBindIP[ 64 ];
  42 + int mPort;
  43 + int mIsShutdown;
  44 + int mIsRunning;
  45 +
  46 + int mTimeout;
  47 + int mMaxThreads;
  48 + int mMaxConnections;
  49 + int mReqQueueSize;
  50 + char * mRefusedMsg;
  51 +
  52 + static sp_thread_result_t SP_THREAD_CALL eventLoop( void * arg );
  53 +
  54 + int start();
  55 +
  56 + static void sigHandler( int, short, void * arg );
  57 +
  58 + static void outputCompleted( void * arg );
  59 +};
  60 +
  61 +#endif
  62 +
注册登录 后发表评论