summaryrefslogtreecommitdiff
path: root/src/client.cpp
diff options
context:
space:
mode:
authorest31 <MTest31@outlook.com>2015-06-29 11:06:03 +0200
committerest31 <MTest31@outlook.com>2015-06-29 15:00:19 +0200
commit29dda9f356042c403b3b7da1d717d32b45c9b6de (patch)
treeac063171e654443370691468175502bd221ac979 /src/client.cpp
parent4e28c8d3c8af51b728a049c28806e0f740ac0106 (diff)
downloadminetest-29dda9f356042c403b3b7da1d717d32b45c9b6de.tar.gz
minetest-29dda9f356042c403b3b7da1d717d32b45c9b6de.tar.bz2
minetest-29dda9f356042c403b3b7da1d717d32b45c9b6de.zip
Add UpdateThread and use it for minimap and mesh threads
Diffstat (limited to 'src/client.cpp')
-rw-r--r--src/client.cpp37
1 files changed, 12 insertions, 25 deletions
diff --git a/src/client.cpp b/src/client.cpp
index ce48df953..b02e6229c 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -139,7 +139,7 @@ void MeshUpdateQueue::addBlock(v3s16 p, MeshMakeData *data, bool ack_block_to_se
// Returned pointer must be deleted
// Returns NULL if queue is empty
-QueuedMeshUpdate * MeshUpdateQueue::pop()
+QueuedMeshUpdate *MeshUpdateQueue::pop()
{
JMutexAutoLock lock(m_mutex);
@@ -162,26 +162,17 @@ QueuedMeshUpdate * MeshUpdateQueue::pop()
MeshUpdateThread
*/
-void * MeshUpdateThread::Thread()
+void MeshUpdateThread::enqueueUpdate(v3s16 p, MeshMakeData *data,
+ bool ack_block_to_server, bool urgent)
{
- ThreadStarted();
-
- log_register_thread("MeshUpdateThread");
-
- DSTACK(__FUNCTION_NAME);
-
- BEGIN_DEBUG_EXCEPTION_HANDLER
-
- porting::setThreadName("MeshUpdateThread");
+ m_queue_in.addBlock(p, data, ack_block_to_server, urgent);
+ deferUpdate();
+}
- while(!StopRequested())
- {
- QueuedMeshUpdate *q = m_queue_in.pop();
- if(q == NULL)
- {
- sleep_ms(3);
- continue;
- }
+void MeshUpdateThread::doUpdate()
+{
+ QueuedMeshUpdate *q;
+ while ((q = m_queue_in.pop())) {
ScopeProfiler sp(g_profiler, "Client: Mesh making");
@@ -196,10 +187,6 @@ void * MeshUpdateThread::Thread()
delete q;
}
-
- END_DEBUG_EXCEPTION_HANDLER(errorstream)
-
- return NULL;
}
/*
@@ -230,7 +217,7 @@ Client::Client(
m_nodedef(nodedef),
m_sound(sound),
m_event(event),
- m_mesh_update_thread(this),
+ m_mesh_update_thread(),
m_env(
new ClientMap(this, this, control,
device->getSceneManager()->getRootSceneNode(),
@@ -1600,7 +1587,7 @@ void Client::addUpdateMeshTask(v3s16 p, bool ack_to_server, bool urgent)
}
// Add task to queue
- m_mesh_update_thread.m_queue_in.addBlock(p, data, ack_to_server, urgent);
+ m_mesh_update_thread.enqueueUpdate(p, data, ack_to_server, urgent);
}
void Client::addUpdateMeshTaskWithEdge(v3s16 blockpos, bool ack_to_server, bool urgent)