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