|
Cuberite
A lightweight, fast and extensible game server for Minecraft
|
Go to the documentation of this file.
12 #include "../Generating/ChunkGenerator.h"
13 #include "../Entities/Entity.h"
14 #include "../BlockEntities/BlockEntity.h"
41 Super(
"World Storage Executor"),
85 LOGD(
"Waiting for the world storage to finish saving");
98 LOGD(
"World storage thread finished");
143 ASSERT((a_ChunkX > -0x08000000) && (a_ChunkX < 0x08000000));
144 ASSERT((a_ChunkZ > -0x08000000) && (a_ChunkZ < 0x08000000));
189 LOGWARNING(
"Unknown storage schema name \"%s\". Using default (\"%s\"). Available schemas:",
194 LOGWARNING(
"\t\"%s\"", (*itr)->GetName().c_str());
289 if (((*itr) !=
m_SaveSchema) && (*itr)->LoadChunk(Coords))
void Initialize(cWorld &a_World, const AString &a_StorageSchemaName, int a_StorageCompressionFactor)
Initializes the storage schemas, ready to be started.
void Wait(void)
Waits until the event has been set.
virtual bool SaveChunk(const cChunkCoords &a_Chunk) override
size_t GetSaveQueueLength(void)
void ChunkLoadFailed(int a_ChunkX, int a_ChunkZ)
Marks the chunk as failed-to-load:
cWSSForgetful(cWorld *a_World)
bool IsChunkQueued(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is in the loader / generator queue.
virtual ~cWorldStorage() override
void WaitForLoadQueueEmpty(void)
void QueueSaveChunk(int a_ChunkX, int a_ChunkZ)
Queues a chunk to be saved, asynchronously.
int NoCaseCompare(const AString &s1, const AString &s2)
Case-insensitive string comparison.
bool IsChunkValid(int a_ChunkX, int a_ChunkZ) const
Returns true iff the chunk is present and valid.
cWSSchemaList m_Schemas
All the storage schemas (all used for loading)
Example storage schema - forgets all chunks.
size_t Size(void)
Returns the size at time of being called.
bool TryDequeueItem(ItemType &item)
Dequeues an item from the queue if any are present.
void InitSchemas(int a_StorageCompressionFactor)
virtual void Execute(void) override
This function, overloaded by the descendants, is called in the new thread.
cEvent m_Event
Set when there's any addition to the queues.
bool LoadOneChunk(void)
Loads one chunk from the queue (if any queued); returns true if there was a chunk in the queue to loa...
cQueue< cChunkCoords > m_SaveQueue
void MarkChunkSaving(int a_ChunkX, int a_ChunkZ)
AString m_StorageSchemaName
void LOGWARNING(std::string_view a_Format, const Args &... args)
void Set(void)
Sets the event - releases one thread that has been waiting in Wait().
void Stop(void)
Signals the thread to terminate and waits until it's finished.
void EnqueueItem(ItemType a_Item)
Enqueues an item to the queue, may block if other threads are accessing the queue.
cQueue< cChunkCoords > m_LoadQueue
virtual const AString GetName(void) const override
void WaitForSaveQueueEmpty(void)
void BlockTillEmpty(void)
Blocks until the queue is empty.
size_t GetLoadQueueLength(void)
bool SaveOneChunk(void)
Saves one chunk from the queue (if any queued); returns true if there was a chunk in the queue to sav...
void QueueLoadChunk(int a_ChunkX, int a_ChunkZ)
Queues a chunk to be loaded, asynchronously.
void Clear(void)
Removes all Items from the Queue, calling Delete on each of them.
std::atomic< bool > m_ShouldTerminate
The overriden Execute() method should check this value periodically and terminate if this is true.
virtual bool LoadChunk(const cChunkCoords &a_Chunk) override
bool LoadChunk(int a_ChunkX, int a_ChunkZ)
Loads the chunk specified; returns true on success, false on failure.
cWSSchema * m_SaveSchema
The one storage schema used for saving.
void MarkChunkSaved(int a_ChunkX, int a_ChunkZ)