Network/SocketPoller: Switch to epoll implementation on Linux

Former-commit-id: 1a4b998bff35b5aac411b053fe3dee48f1f6985c [formerly b7a50753347b629f708f21d85efc9e76e4b1bfc6] [formerly 7d59f9ff3d2173657cc5873209753fe64b59e2f2 [formerly 4c38f94a4a366ed290e605870e6f3c87e6decd7f]]
Former-commit-id: af5cc261c162ca3eebe5885acd5e2adfbd817984 [formerly 26e7b701e8dcafb7fb9c3537107729b2d0bfe354]
Former-commit-id: 00bd2c62ecdb5c493c4ec117dd2033d272f7143a
This commit is contained in:
Lynix
2016-09-26 18:34:06 +02:00
parent 72680be701
commit a13b17573e
3 changed files with 147 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
// Copyright (C) 2015 Jérôme Leclercq
// This file is part of the "Nazara Engine - Network module"
// For conditions of distribution and use, see copyright notice in Config.hpp
#pragma once
#ifndef NAZARA_SOCKETPOLLERIMPL_HPP
#define NAZARA_SOCKETPOLLERIMPL_HPP
#include <Nazara/Network/IpAddress.hpp>
#include <Nazara/Network/SocketHandle.hpp>
#include <Nazara/Network/Posix/SocketImpl.hpp>
#include <unordered_set>
#include <vector>
#include <sys/epoll.h>
namespace Nz
{
class SocketPollerImpl
{
public:
SocketPollerImpl();
~SocketPollerImpl();
void Clear();
bool IsReady(SocketHandle socket) const;
bool IsRegistered(SocketHandle socket) const;
bool RegisterSocket(SocketHandle socket);
void UnregisterSocket(SocketHandle socket);
int Wait(UInt64 msTimeout, SocketError* error);
private:
std::unordered_set<SocketHandle> m_activeSockets;
std::unordered_set<SocketHandle> m_sockets;
std::vector<epoll_event> m_events;
int m_handle;
};
}
#endif // NAZARA_SOCKETPOLLERIMPL_HPP