Added PollManager class

This commit is contained in:
ouafabulous 2025-05-19 20:23:22 +02:00
parent 53a83308de
commit 4a17d88d80
7 changed files with 179 additions and 37 deletions

View file

@ -0,0 +1,30 @@
/******************************************************************************/
/* */
/* ::: :::::::: */
/* pollManager.hpp :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omoudni <omoudni@student.42paris.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/05/19 19:15:13 by omoudni #+# #+# */
/* Updated: 2025/05/19 19:25:45 by omoudni ### ########.fr */
/* */
/******************************************************************************/
#pragma once
#include <vector>
#include <poll.h>
#include <map>
class PollManager {
private:
std::vector<struct pollfd> _fds;
std::map<int, short> _fd_events; // fd -> event
public:
PollManager();
void addFd(int fd, short events);
void removeFd(int fd);
void updateFd(int fd, short events);
int pollEvents(int timeout = -1);
const std::vector<struct pollfd>& getFds() const;
};