mirror of
https://github.com/Redot-Engine/redot-engine.git
synced 2025-12-05 23:07:42 -05:00
Ensure that threads only process one pump task.
This is necessary because we will always deadlock if a thread takes on multiple pump tasks since pump tasks never return. This means when using separate threads for certain systems (like physics or rendering), we need to be sure that there are enough threads to have at least one per system (to ensure forward progress).
This commit is contained in:
@@ -75,7 +75,7 @@ void PhysicsServer2DWrapMT::end_sync() {
|
||||
|
||||
void PhysicsServer2DWrapMT::init() {
|
||||
if (create_thread) {
|
||||
WorkerThreadPool::TaskID tid = WorkerThreadPool::get_singleton()->add_task(callable_mp(this, &PhysicsServer2DWrapMT::_thread_loop), true);
|
||||
WorkerThreadPool::TaskID tid = WorkerThreadPool::get_singleton()->add_task(callable_mp(this, &PhysicsServer2DWrapMT::_thread_loop), true, "Physics server 2D pump task", true);
|
||||
command_queue.set_pump_task_id(tid);
|
||||
command_queue.push(this, &PhysicsServer2DWrapMT::_assign_mt_ids, tid);
|
||||
command_queue.push_and_sync(physics_server_2d, &PhysicsServer2D::init);
|
||||
|
||||
@@ -75,7 +75,7 @@ void PhysicsServer3DWrapMT::end_sync() {
|
||||
|
||||
void PhysicsServer3DWrapMT::init() {
|
||||
if (create_thread) {
|
||||
WorkerThreadPool::TaskID tid = WorkerThreadPool::get_singleton()->add_task(callable_mp(this, &PhysicsServer3DWrapMT::_thread_loop), true);
|
||||
WorkerThreadPool::TaskID tid = WorkerThreadPool::get_singleton()->add_task(callable_mp(this, &PhysicsServer3DWrapMT::_thread_loop), true, "Physics server 3D pump task", true);
|
||||
command_queue.set_pump_task_id(tid);
|
||||
command_queue.push(this, &PhysicsServer3DWrapMT::_assign_mt_ids, tid);
|
||||
command_queue.push_and_sync(physics_server_3d, &PhysicsServer3D::init);
|
||||
|
||||
@@ -253,7 +253,7 @@ void RenderingServerDefault::init() {
|
||||
if (create_thread) {
|
||||
print_verbose("RenderingServerWrapMT: Starting render thread");
|
||||
DisplayServer::get_singleton()->release_rendering_thread();
|
||||
WorkerThreadPool::TaskID tid = WorkerThreadPool::get_singleton()->add_task(callable_mp(this, &RenderingServerDefault::_thread_loop), true);
|
||||
WorkerThreadPool::TaskID tid = WorkerThreadPool::get_singleton()->add_task(callable_mp(this, &RenderingServerDefault::_thread_loop), true, "Rendering Server pump task", true);
|
||||
command_queue.set_pump_task_id(tid);
|
||||
command_queue.push(this, &RenderingServerDefault::_assign_mt_ids, tid);
|
||||
command_queue.push_and_sync(this, &RenderingServerDefault::_init);
|
||||
|
||||
Reference in New Issue
Block a user