Network: Add SocketPoller class

Former-commit-id: 86b9266d904551d19e7ec8e8d6bbe5f137e8d29f [formerly 34575937d84f796cfe36a5ab97ea1f787c1506ba] [formerly 6c8c621523800958ad38eef118fcb3687c34b367 [formerly a1f1330fbe6f990a21bbe6dccfe727edec0e2b44]]
Former-commit-id: 6635c463a753f744b835267181b51ed89620b627 [formerly 14e84c7155cd669ac20a5492e67704059a442925]
Former-commit-id: 7becccdf2d8aac7cdf526d855215d7d144be284c
This commit is contained in:
Lynix
2016-09-22 18:16:39 +02:00
parent 0a656ca398
commit 9452b98f49
13 changed files with 667 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
// 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/Win32/SocketImpl.hpp>
#include <unordered_map>
#include <unordered_set>
#include <vector>
namespace Nz
{
class SocketPollerImpl
{
public:
SocketPollerImpl() = default;
~SocketPollerImpl() = default;
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_map<SocketHandle, std::size_t> m_allSockets;
std::vector<PollSocket> m_sockets;
};
}
#endif // NAZARA_SOCKETPOLLERIMPL_HPP