diff options
author | est31 <MTest31@outlook.com> | 2015-06-27 18:11:24 +0200 |
---|---|---|
committer | est31 <MTest31@outlook.com> | 2015-06-27 19:20:25 +0200 |
commit | 420125debd3d010fcd3e7738c43f25c8f407ab63 (patch) | |
tree | 14df90c0ea0bb2c38635b8bba3404e19cc36a43e /src/minimap.h | |
parent | 36163d96533313f8fd336c04911383569582acc1 (diff) | |
download | minetest-420125debd3d010fcd3e7738c43f25c8f407ab63.tar.gz minetest-420125debd3d010fcd3e7738c43f25c8f407ab63.tar.bz2 minetest-420125debd3d010fcd3e7738c43f25c8f407ab63.zip |
Remove busy polling inside minimap thread
Diffstat (limited to 'src/minimap.h')
-rw-r--r-- | src/minimap.h | 13 |
1 files changed, 10 insertions, 3 deletions
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 <map> #include <string> #include <vector> @@ -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<QueuedMinimapUpdate*> m_queue; + std::list<QueuedMinimapUpdate*> 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<v3s16, MinimapMapblock *> m_blocks_cache; }; |