-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPoller.h
More file actions
39 lines (32 loc) · 958 Bytes
/
Copy pathPoller.h
File metadata and controls
39 lines (32 loc) · 958 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
#ifndef Poller_h
#define Poller_h
#include"noncopyable.h"
#include"Timestamp.h"
#include<vector>
#include<unordered_map>
#include<memory>
class Channel;
class EventLoop;
class Poller:noncopyable
{
private:
/* data */
EventLoop* ownerloop_;
protected:
using ChannelUnorderMap = std::unordered_map<int,Channel*>;
ChannelUnorderMap Channels_;
public:
using ChannelList = std::vector<Channel*>;
/**IO复用提供的统一接口*/
virtual Timestamp poll(int timeout,ChannelList* activeChannel) = 0 ;
virtual void updateChannel(Channel* channel) = 0 ;
virtual void removeChannel(Channel* channel) = 0;
/**判断当前的poller是否有指定channel*/
bool hasChannel(Channel* target)const;
/**根据EventLoop 返回单例poller*/
static std::unique_ptr<Poller> newDefaultPoller(EventLoop* loop);
Poller(EventLoop* loop);
Poller(/* args */) = default;
virtual ~Poller() = default;
};
#endif