From 499745c1c7a865941b3c102532777c19dfb92ca4 Mon Sep 17 00:00:00 2001 From: "madmaxoft@gmail.com" Date: Sat, 18 Feb 2012 17:53:22 +0000 Subject: Thread-safe chunk generation, storage and generator are queried for progress while initializing server Note that this commit breaks foliage generation - there are no trees in the chunks generated! git-svn-id: http://mc-server.googlecode.com/svn/trunk@292 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/WorldStorage.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'source/WorldStorage.h') diff --git a/source/WorldStorage.h b/source/WorldStorage.h index 220585c57..1ea39cf66 100644 --- a/source/WorldStorage.h +++ b/source/WorldStorage.h @@ -105,19 +105,23 @@ public: bool Start(cWorld * a_World, const AString & a_StorageSchemaName); // Hide the cIsThread's Start() method, we need to provide args void WaitForFinish(void); + void WaitForQueuesEmpty(void); + + int GetLoadQueueLength(void); + int GetSaveQueueLength(void); protected: cWorld * m_World; AString m_StorageSchemaName; - cCriticalSection m_CSLoadQueue; - cChunkCoordsList m_LoadQueue; - - cCriticalSection m_CSSaveQueue; - cChunkCoordsList m_SaveQueue; + // Both queues are locked by the same CS + cCriticalSection m_CSQueues; + cChunkCoordsList m_LoadQueue; + cChunkCoordsList m_SaveQueue; - cEvent m_Event; // Set when there's any addition to the queues + cEvent m_Event; // Set when there's any addition to the queues + cEvent m_evtRemoved; // Set when an item has been removed from the queue, either by the worker thread or the Unqueue methods /// All the storage schemas (all used for loading) cWSSchemaList m_Schemas; -- cgit v1.2.3