Core/MemoryPool: Remake memory pool

This commit is contained in:
Jérôme Leclercq
2022-02-20 16:00:32 +01:00
parent c3ace0dadc
commit 29c798a683
7 changed files with 292 additions and 183 deletions

View File

@@ -145,7 +145,7 @@ namespace Nz
std::vector<PendingOutgoingPacket> m_pendingOutgoingPackets;
MovablePtr<UInt8> m_receivedData;
Bitset<UInt64> m_dispatchQueue;
MemoryPool m_packetPool;
MemoryPool<ENetPacket> m_packetPool;
IpAddress m_address;
IpAddress m_receivedAddress;
SocketPoller m_poller;

View File

@@ -8,6 +8,7 @@
#define NAZARA_NETWORK_ENETPACKET_HPP
#include <Nazara/Prerequisites.hpp>
#include <Nazara/Core/MemoryPool.hpp>
#include <Nazara/Network/NetPacket.hpp>
namespace Nz
@@ -29,13 +30,11 @@ namespace Nz
constexpr ENetPacketFlags ENetPacketFlag_Unreliable = 0;
class MemoryPool;
struct ENetPacket
{
MemoryPool* owner;
ENetPacketFlags flags;
NetPacket data;
std::size_t poolIndex;
std::size_t referenceCount = 0;
};
@@ -54,7 +53,7 @@ namespace Nz
Reset(packet);
}
ENetPacketRef(ENetPacketRef&& packet) :
ENetPacketRef(ENetPacketRef&& packet) noexcept :
m_packet(packet.m_packet)
{
packet.m_packet = nullptr;
@@ -91,7 +90,7 @@ namespace Nz
return *this;
}
ENetPacketRef& operator=(ENetPacketRef&& packet)
ENetPacketRef& operator=(ENetPacketRef&& packet) noexcept
{
m_packet = packet.m_packet;
packet.m_packet = nullptr;
@@ -99,6 +98,7 @@ namespace Nz
return *this;
}
MemoryPool<ENetPacket>* m_pool = nullptr;
ENetPacket* m_packet = nullptr;
};
}