forked from lxyfirst/id_server
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpipe_handler.h
More file actions
executable file
·53 lines (42 loc) · 1015 Bytes
/
Copy pathpipe_handler.h
File metadata and controls
executable file
·53 lines (42 loc) · 1015 Bytes
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
/*
* pipe_handler.h
* Author: lixingyi (lxyfirst@163.com)
*/
#ifndef PIPE_HANDLER_H_
#define PIPE_HANDLER_H_
#include <stdint.h>
#include <tr1/functional>
#include "io_handler.h"
namespace framework
{
class base_reactor ;
struct packet_info ;
class pipe_handler : public io_handler
{
public:
typedef std::tr1::function<void (const packet_info*) > callback_type ;
public:
pipe_handler() ;
virtual ~pipe_handler();
public:
/*
* @return: 0 on success
*/
int init(base_reactor& reactor,int pipe_fd,const callback_type& callback) ;
void fini() ;
/*
* @return: 0 on success
*/
int send_pipe_message(const packet_info* msg) ;
int send_pipe_message(const char* data,int size) ;
protected:
void on_read(int fd) ;
void on_write(int fd) ;
void on_error(int fd) ;
private:
callback_type m_callback ;
base_reactor* m_reactor ;
int m_pipe_fd ;
};
}
#endif /* PIPE_HANDLER_H_ */