SpiecsEngine
 
Loading...
Searching...
No Matches
EPollPoller.h
Go to the documentation of this file.
1/**
2* @file EPollPoller.h.
3* @brief The EPollPoller Class Definitions.
4* @author Spices & Muduo.
5*/
6
7#pragma once
8#include "Poller.h"
9
10#include <wepoll.h>
11
12namespace Spices {
13
14namespace Net {
15
16 /**
17 * @brief EPoll Poller.
18 */
19 class EPollPoller : public Poller
20 {
21 public:
22
24
25 public:
26
27 /**
28 * @brief Constructor Function.
29 * @param[in] loop EventLoop.
30 */
32
33 /**
34 * @brief Destructor Function.
35 */
36 virtual ~EPollPoller() override;
37
38 /**
39 * @brief Copy Constructor Function.
40 * @note This Class not allowed copy behaves.
41 */
42 EPollPoller(const EPollPoller&) = delete;
43
44 /**
45 * @brief Copy Assignment Operation.
46 * @note This Class not allowed copy behaves.
47 */
48 EPollPoller& operator=(const EPollPoller&) = delete;
49
50 /**
51 * @brief Get this EPollPoller Handle.
52 * @return Return this EPollPoller Handle.
53 */
54 HANDLE GetHandle() const { return m_EPollFd; }
55
56 /**
57 * @brief Poll events on EventList.
58 * @param[in] timeoutMs .
59 * @param[in,out] activeChannels Channels that events happened.
60 */
61 virtual void Poll(int timeoutMs, ChannelList* activeChannels) override;
62
63 /**
64 * @brief Update Channel and Update Poll.
65 * @param[in] channel Channel.
66 */
67 virtual void UpdateChannel(Channel* channel) override;
68
69 /**
70 * @brief Remove Channel and Update Poll.
71 * @param[in] channel Channel.
72 */
73 virtual void RemoveChannel(Channel* channel) override;
74
75 private:
76
77 /**
78 * @brief Fill REvents to ChannelList.
79 * @param[in] numEvents .
80 * @param[in] activeChannels ChannelList.
81 */
82 void FillActiveChannels(int numEvents, ChannelList* activeChannels) const;
83
84 /**
85 * @brief Update epoll with operation.
86 * @param[in] operation .
87 * @param[in] channel Channel.
88 */
89 void Update(int operation, Channel* channel) const;
90
91 private:
92
93 /**
94 * @brief EPoll fd.
95 */
97
98 /**
99 * @brief EventList.
100 */
102 };
103}
104
105}
void SetPollState(PollState state)
Set Poll State.
Definition Channel.h:208
PollState GetPollState() const
Get Poll State.
Definition Channel.h:202
bool IsNoneEvent() const
Determine whether the event is a None Event.
Definition Channel.h:184
Wrapper of SOCKET'S Event.
Definition Channel.h:27
EPollPoller(const EPollPoller &)=delete
Copy Constructor Function.
HANDLE m_EPollFd
EPoll fd.
Definition EPollPoller.h:96
virtual ~EPollPoller() override
Destructor Function.
void Update(int operation, Channel *channel) const
Update epoll with operation.
virtual void Poll(int timeoutMs, ChannelList *activeChannels) override
Poll events on EventList.
virtual void UpdateChannel(Channel *channel) override
Update Channel and Update Poll.
virtual void RemoveChannel(Channel *channel) override
Remove Channel and Update Poll.
EPollPoller & operator=(const EPollPoller &)=delete
Copy Assignment Operation.
EventList m_Events
EventList.
void FillActiveChannels(int numEvents, ChannelList *activeChannels) const
Fill REvents to ChannelList.
EPollPoller(EventLoop *loop)
Constructor Function.
HANDLE GetHandle() const
Get this EPollPoller Handle.
Definition EPollPoller.h:54
Wrapper of Poller and wakeup socket to acceptor(SubLoop).
Definition EventLoop.h:28
Poller(EventLoop *loop)
Constructor Function.
Definition Poller.h:37
Inherit from this and Implement Specific Poller.
Definition Poller.h:25
static constexpr int InitEventListSize