true atomic EnttWorld

This commit is contained in:
2024-07-23 01:10:20 +02:00
parent 392eaeab83
commit 89d5ad5f54
16 changed files with 61 additions and 35 deletions

View File

@@ -1,9 +1,31 @@
#pragma once
#include <cstdint>
#include <Nazara/Core/EnttWorld.hpp>
namespace blitz {
struct AtomicEnttWorld {
Nz::EnttWorld& m_World;
std::lock_guard<std::mutex> m_LockGuard;
Nz::EnttWorld* operator->() {
return &m_World;
}
};
struct EnttWorld {
Nz::EnttWorld& m_World;
std::mutex m_Mutex;
/**
* \return an AtomicEnttWorld structure which will lock the associated mutex until destruction
* \warning Do not hold more than one instance or the current thread will self lock
*/
operator AtomicEnttWorld() {
return {m_World, std::lock_guard<std::mutex>(m_Mutex)};
}
};
using EntityID = std::uint32_t;
} // namespace blitz

View File

@@ -4,9 +4,6 @@
#include <blitz/network/EnetConnection.h>
namespace blitz {
using EnttWorld = std::atomic<std::shared_ptr<Nz::EnttWorld>>;
namespace protocol {
class PacketHandler : private NonCopyable {