[GDNative] Why can't I call _new() inside a thread using std::thread?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Ducku

Im trying to create a multi threaded mesh generation algorithm (which generates one mesh per thread) but once a thread hits the _new() function (ArrayMesh::_new() in particular) it hangs indefinitely. Is this an engine limitation or is it something I’m doing wrong? And if the former, any resources on why this is the case?

Maybe the _new() function is waiting for a thread to open, and so the code has to check for the thread to be unlocked? Have you looked at the documentation page that discusses thread safety?

Ertain | 2020-10-28 16:26

That doc page doesn’t seem to apply to std threads as it says creating nodes outside of the main scene is fine on different threads.

Ducku | 2020-10-28 16:30