true atomic EnttWorld
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user