VOX
A little voxel engine
Loading...
Searching...
No Matches
Poller.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "Socket.hpp"
4#include <cstring>
5#include <memory>
6#include <sys/epoll.h>
7
8#define EVENTS_SIZE 20
9
10class Socket;
11
12class Poller
13{
14public:
15 Poller();
16 virtual ~Poller();
17
18 Poller(const Poller& other) = delete;
19 Poller& operator=(const Poller& other) = delete;
20
21 Poller(Poller&& other);
22 Poller& operator=(Poller&& other);
23
24 void add(const uint64_t & id, const Socket & socket);
25 void remove(const Socket & socket);
26 std::pair<size_t, epoll_event*> wait(const int & timeout_ms);
27private:
28 int m_epolld_fd = -1;
29 epoll_event m_events[EVENTS_SIZE];
30
31 void close();
32};
#define EVENTS_SIZE
Definition: Poller.hpp:8
Definition: Poller.hpp:13
Poller & operator=(const Poller &other)=delete
virtual ~Poller()
Definition: Poller.cpp:14
void remove(const Socket &socket)
Definition: Poller.cpp:57
std::pair< size_t, epoll_event * > wait(const int &timeout_ms)
Definition: Poller.cpp:63
void add(const uint64_t &id, const Socket &socket)
Definition: Poller.cpp:47
Poller(const Poller &other)=delete
Poller()
Definition: Poller.cpp:4
a RAII wrapper for a socket.
Definition: Socket.hpp:17