Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
cWorldStorage Class Reference

The actual world storage class. More...

#include <WorldStorage.h>

Inheritance diagram for cWorldStorage:
Inheritance graph
[legend]
Collaboration diagram for cWorldStorage:
Collaboration graph
[legend]

Public Member Functions

 cWorldStorage ()
 
size_t GetLoadQueueLength (void)
 
size_t GetSaveQueueLength (void)
 
void Initialize (cWorld &a_World, const AString &a_StorageSchemaName, int a_StorageCompressionFactor)
 Initializes the storage schemas, ready to be started. More...
 
void QueueLoadChunk (int a_ChunkX, int a_ChunkZ)
 Queues a chunk to be loaded, asynchronously. More...
 
void QueueSaveChunk (int a_ChunkX, int a_ChunkZ)
 Queues a chunk to be saved, asynchronously. More...
 
void Stop (void)
 
void WaitForFinish (void)
 
void WaitForLoadQueueEmpty (void)
 
void WaitForSaveQueueEmpty (void)
 
virtual ~cWorldStorage () override
 
- Public Member Functions inherited from cIsThread
 cIsThread (AString &&a_ThreadName)
 
bool IsCurrentThread (void) const
 Returns true if the thread calling this function is the thread contained within this object. More...
 
void Start (void)
 Starts the thread; returns without waiting for the actual start. More...
 
void Stop (void)
 Signals the thread to terminate and waits until it's finished. More...
 
virtual ~cIsThread ()
 

Protected Member Functions

virtual void Execute (void) override
 This function, overloaded by the descendants, is called in the new thread. More...
 
void InitSchemas (int a_StorageCompressionFactor)
 
bool LoadChunk (int a_ChunkX, int a_ChunkZ)
 Loads the chunk specified; returns true on success, false on failure. More...
 
bool LoadOneChunk (void)
 Loads one chunk from the queue (if any queued); returns true if there was a chunk in the queue to load. More...
 
bool SaveOneChunk (void)
 Saves one chunk from the queue (if any queued); returns true if there was a chunk in the queue to save. More...
 

Protected Attributes

cEvent m_Event
 Set when there's any addition to the queues. More...
 
cQueue< cChunkCoordsm_LoadQueue
 
cQueue< cChunkCoordsm_SaveQueue
 
cWSSchema * m_SaveSchema
 The one storage schema used for saving. More...
 
cWSSchemaList m_Schemas
 All the storage schemas (all used for loading) More...
 
AString m_StorageSchemaName
 
cWorldm_World
 
- Protected Attributes inherited from cIsThread
std::atomic< bool > m_ShouldTerminate
 The overriden Execute() method should check this value periodically and terminate if this is true. More...
 

Private Types

using Super = cIsThread
 

Detailed Description

The actual world storage class.

Definition at line 52 of file WorldStorage.h.

Member Typedef Documentation

◆ Super

Definition at line 55 of file WorldStorage.h.

Constructor & Destructor Documentation

◆ cWorldStorage()

cWorldStorage::cWorldStorage ( void  )

Definition at line 40 of file WorldStorage.cpp.

◆ ~cWorldStorage()

cWorldStorage::~cWorldStorage ( )
overridevirtual

Definition at line 51 of file WorldStorage.cpp.

Member Function Documentation

◆ Execute()

void cWorldStorage::Execute ( void  )
overrideprotectedvirtual

This function, overloaded by the descendants, is called in the new thread.

Implements cIsThread.

Definition at line 203 of file WorldStorage.cpp.

◆ GetLoadQueueLength()

size_t cWorldStorage::GetLoadQueueLength ( void  )

Definition at line 123 of file WorldStorage.cpp.

◆ GetSaveQueueLength()

size_t cWorldStorage::GetSaveQueueLength ( void  )

Definition at line 132 of file WorldStorage.cpp.

◆ Initialize()

void cWorldStorage::Initialize ( cWorld a_World,
const AString a_StorageSchemaName,
int  a_StorageCompressionFactor 
)

Initializes the storage schemas, ready to be started.

Definition at line 63 of file WorldStorage.cpp.

◆ InitSchemas()

void cWorldStorage::InitSchemas ( int  a_StorageCompressionFactor)
protected

Definition at line 167 of file WorldStorage.cpp.

◆ LoadChunk()

bool cWorldStorage::LoadChunk ( int  a_ChunkX,
int  a_ChunkZ 
)
protected

Loads the chunk specified; returns true on success, false on failure.

Definition at line 274 of file WorldStorage.cpp.

◆ LoadOneChunk()

bool cWorldStorage::LoadOneChunk ( void  )
protected

Loads one chunk from the queue (if any queued); returns true if there was a chunk in the queue to load.

Definition at line 227 of file WorldStorage.cpp.

◆ QueueLoadChunk()

void cWorldStorage::QueueLoadChunk ( int  a_ChunkX,
int  a_ChunkZ 
)

Queues a chunk to be loaded, asynchronously.

Definition at line 141 of file WorldStorage.cpp.

◆ QueueSaveChunk()

void cWorldStorage::QueueSaveChunk ( int  a_ChunkX,
int  a_ChunkZ 
)

Queues a chunk to be saved, asynchronously.

Definition at line 155 of file WorldStorage.cpp.

◆ SaveOneChunk()

bool cWorldStorage::SaveOneChunk ( void  )
protected

Saves one chunk from the queue (if any queued); returns true if there was a chunk in the queue to save.

Definition at line 247 of file WorldStorage.cpp.

◆ Stop()

void cWorldStorage::Stop ( void  )

Definition at line 74 of file WorldStorage.cpp.

◆ WaitForFinish()

void cWorldStorage::WaitForFinish ( void  )

Definition at line 83 of file WorldStorage.cpp.

◆ WaitForLoadQueueEmpty()

void cWorldStorage::WaitForLoadQueueEmpty ( void  )

Definition at line 105 of file WorldStorage.cpp.

◆ WaitForSaveQueueEmpty()

void cWorldStorage::WaitForSaveQueueEmpty ( void  )

Definition at line 114 of file WorldStorage.cpp.

Member Data Documentation

◆ m_Event

cEvent cWorldStorage::m_Event
protected

Set when there's any addition to the queues.

Definition at line 93 of file WorldStorage.h.

◆ m_LoadQueue

cQueue<cChunkCoords> cWorldStorage::m_LoadQueue
protected

Definition at line 83 of file WorldStorage.h.

◆ m_SaveQueue

cQueue<cChunkCoords> cWorldStorage::m_SaveQueue
protected

Definition at line 84 of file WorldStorage.h.

◆ m_SaveSchema

cWSSchema* cWorldStorage::m_SaveSchema
protected

The one storage schema used for saving.

Definition at line 90 of file WorldStorage.h.

◆ m_Schemas

cWSSchemaList cWorldStorage::m_Schemas
protected

All the storage schemas (all used for loading)

Definition at line 87 of file WorldStorage.h.

◆ m_StorageSchemaName

AString cWorldStorage::m_StorageSchemaName
protected

Definition at line 81 of file WorldStorage.h.

◆ m_World

cWorld* cWorldStorage::m_World
protected

Definition at line 80 of file WorldStorage.h.


The documentation for this class was generated from the following files: