mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add UpdateThread and use it for minimap and mesh threads
This commit is contained in:
parent
4e28c8d3c8
commit
29dda9f356
5 changed files with 114 additions and 98 deletions
|
@ -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();
|
||||
m_queue_in.addBlock(p, data, ack_block_to_server, urgent);
|
||||
deferUpdate();
|
||||
}
|
||||
|
||||
log_register_thread("MeshUpdateThread");
|
||||
|
||||
DSTACK(__FUNCTION_NAME);
|
||||
|
||||
BEGIN_DEBUG_EXCEPTION_HANDLER
|
||||
|
||||
porting::setThreadName("MeshUpdateThread");
|
||||
|
||||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue