From 420125debd3d010fcd3e7738c43f25c8f407ab63 Mon Sep 17 00:00:00 2001 From: est31 Date: Sat, 27 Jun 2015 18:11:24 +0200 Subject: Remove busy polling inside minimap thread --- src/minimap.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/minimap.h') diff --git a/src/minimap.h b/src/minimap.h index ebb74c4fb..1794da190 100644 --- a/src/minimap.h +++ b/src/minimap.h @@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "client.h" #include "voxel.h" #include "jthread/jmutex.h" +#include "jthread/jsemaphore.h" #include #include #include @@ -93,8 +94,9 @@ public: ~MinimapUpdateQueue(); - void addBlock(v3s16 pos, MinimapMapblock *data); + bool addBlock(v3s16 pos, MinimapMapblock *data); + // blocking!! QueuedMinimapUpdate *pop(); u32 size() @@ -104,13 +106,15 @@ public: } private: - std::vector m_queue; + std::list m_queue; JMutex m_mutex; }; class MinimapUpdateThread : public JThread { private: + JSemaphore m_queue_sem; + MinimapUpdateQueue m_queue; public: MinimapUpdateThread(IrrlichtDevice *device, Client *client) @@ -124,13 +128,16 @@ public: MinimapPixel *getMinimapPixel (v3s16 pos, s16 height, s16 &pixel_height); s16 getAirCount (v3s16 pos, s16 height); video::SColor getColorFromId(u16 id); + + void enqueue_Block(v3s16 pos, MinimapMapblock *data); + IrrlichtDevice *device; Client *client; video::IVideoDriver *driver; ITextureSource *tsrc; + void Stop(); void *Thread(); MinimapData *data; - MinimapUpdateQueue m_queue; std::map m_blocks_cache; }; -- cgit v1.2.3