-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathio_handler.h
69 lines (48 loc) · 1.09 KB
/
io_handler.h
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
/*
* io_handler.h
*
* Created on: 2011-10-14
* Author: gxl2007@hotmail.com
*/
#ifndef IO_HANDLER_H_
#define IO_HANDLER_H_
namespace xlnet
{
enum
{
ERROR_TYPE_NONE = 0 ,
ERROR_TYPE_SYSTEM = 1 ,
ERROR_TYPE_MEMORY = 2 ,
ERROR_TYPE_REQUEST = 3 ,
ERROR_TYPE_TIMEOUT = 4 ,
ERROR_TYPE_PEER_CLOSE = 5 ,
ERROR_TYPE_ACTIVE_CLOSE = 6 ,
};
/*
* @brief interface for event driven handler
*/
class io_handler
{
friend class epoll_reactor ;
public:
io_handler(){ } ;
virtual ~io_handler() { } ;
protected :
/*
* @brief error events callback , implemented by concrete class
*/
virtual void on_error(int fd) = 0 ;
/*
* @brief read events callback , implemented by concrete class
*/
virtual void on_read(int fd) = 0 ;
/*
* @brief write events callback , implemented by concrete class
*/
virtual void on_write(int fd) = 0 ;
private:
io_handler(const io_handler& ) ;
io_handler& operator=(const io_handler&) ;
};
}
#endif /* IO_HANDLER_H_ */