-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnotify_handler.h
66 lines (42 loc) · 955 Bytes
/
notify_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
/*
* notify_handler.h
*
* Created on: 2011-10-22
* Author: gxl2007@hotmail.com
*/
#ifndef NOTIFY_HANDLER_H
#define NOTIFY_HANDLER_H
#include <stdlib.h>
#include <stdint.h>
#include "io_handler.h"
namespace xlnet
{
/*
* @brief notify handler for pipe
*/
class notify_handler : public io_handler
{
public:
notify_handler() : m_fd(-1) { } ;
virtual ~notify_handler() { } ;
int fd() const { return m_fd ;} ;
void set_fd(int fd) { m_fd = fd ; } ;
/*
* @brief send notify signal to pipe
*/
int send_notify() ;
protected:
/*
* @brief callback implemented by concrete class
* called when get notify signal
*/
virtual void on_notify() = 0 ;
protected:
virtual void on_read(int fd) ;
virtual void on_write(int fd) ;
virtual void on_error(int fd) ;
private:
int32_t m_fd ;
} ;
}
#endif