提交 31f1bcabb191c452d06de36475a9b3a758b91005

作者 LJH 李佳桓
1 个父辈 a9d4ce87

add

正在显示 1 个修改的文件 包含 97 行增加0 行删除
  1 +/*
  2 + * Copyright 2007 Stephen Liu
  3 + * For license terms, see the file COPYING along with this library.
  4 + */
  5 +
  6 +#ifndef __speventcb_hpp__
  7 +#define __speventcb_hpp__
  8 +
  9 +class SP_HandlerFactory;
  10 +class SP_SessionManager;
  11 +class SP_Session;
  12 +class SP_BlockingQueue;
  13 +class SP_Message;
  14 +class SP_IOChannelFactory;
  15 +
  16 +struct event_base;
  17 +typedef struct tagSP_Sid SP_Sid_t;
  18 +
  19 +class SP_EventArg {
  20 +public:
  21 + SP_EventArg( int timeout );
  22 + ~SP_EventArg();
  23 +
  24 + struct event_base * getEventBase() const;
  25 + void * getResponseQueue() const;
  26 + SP_BlockingQueue * getInputResultQueue() const;
  27 + SP_BlockingQueue * getOutputResultQueue() const;
  28 + SP_SessionManager * getSessionManager() const;
  29 +
  30 + void setTimeout( int timeout );
  31 + int getTimeout() const;
  32 +
  33 +private:
  34 + struct event_base * mEventBase;
  35 + void * mResponseQueue;
  36 +
  37 + SP_BlockingQueue * mInputResultQueue;
  38 + SP_BlockingQueue * mOutputResultQueue;
  39 +
  40 + SP_SessionManager * mSessionManager;
  41 +
  42 + int mTimeout;
  43 +};
  44 +
  45 +typedef struct tagSP_AcceptArg {
  46 + SP_EventArg * mEventArg;
  47 +
  48 + SP_HandlerFactory * mHandlerFactory;
  49 + SP_IOChannelFactory * mIOChannelFactory;
  50 + int mReqQueueSize;
  51 + int mMaxConnections;
  52 + char * mRefusedMsg;
  53 +} SP_AcceptArg_t;
  54 +
  55 +class SP_EventCallback {
  56 +public:
  57 + static void onAccept( int fd, short events, void * arg );
  58 + static void onRead( int fd, short events, void * arg );
  59 + static void onWrite( int fd, short events, void * arg );
  60 +
  61 + static void onResponse( void * queueData, void * arg );
  62 +
  63 + static void addEvent( SP_Session * session, short events, int fd );
  64 +
  65 +private:
  66 + SP_EventCallback();
  67 + ~SP_EventCallback();
  68 +};
  69 +
  70 +class SP_EventHelper {
  71 +public:
  72 + static void doStart( SP_Session * session );
  73 + static void start( void * arg );
  74 +
  75 + static void doWork( SP_Session * session );
  76 + static void worker( void * arg );
  77 +
  78 + static void doError( SP_Session * session );
  79 + static void error( void * arg );
  80 +
  81 + static void doTimeout( SP_Session * session );
  82 + static void timeout( void * arg );
  83 +
  84 + static void doClose( SP_Session * session );
  85 + static void myclose( void * arg );
  86 +
  87 + static void doCompletion( SP_EventArg * eventArg, SP_Message * msg );
  88 +
  89 + static int isSystemSid( SP_Sid_t * sid );
  90 +
  91 +private:
  92 + SP_EventHelper();
  93 + ~SP_EventHelper();
  94 +};
  95 +
  96 +#endif
  97 +
注册登录 后发表评论