You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-05 12:10:55 +00:00
Replace CreateThread with QueueUserWorkItem
Fixes #24869 stuttering on Windows by reusing long running threadpool threads instead of creating a new thread on each call to Thread::start.
This commit is contained in:
@@ -52,6 +52,7 @@ DWORD ThreadWindows::thread_callback(LPVOID userdata) {
|
|||||||
|
|
||||||
t->id = (ID)GetCurrentThreadId(); // must implement
|
t->id = (ID)GetCurrentThreadId(); // must implement
|
||||||
t->callback(t->user);
|
t->callback(t->user);
|
||||||
|
SetEvent(t->handle);
|
||||||
|
|
||||||
ScriptServer::thread_exit();
|
ScriptServer::thread_exit();
|
||||||
|
|
||||||
@@ -63,13 +64,9 @@ Thread *ThreadWindows::create_func_windows(ThreadCreateCallback p_callback, void
|
|||||||
ThreadWindows *tr = memnew(ThreadWindows);
|
ThreadWindows *tr = memnew(ThreadWindows);
|
||||||
tr->callback = p_callback;
|
tr->callback = p_callback;
|
||||||
tr->user = p_user;
|
tr->user = p_user;
|
||||||
tr->handle = CreateThread(
|
tr->handle = CreateEvent(NULL, TRUE, FALSE, NULL);
|
||||||
NULL, // default security attributes
|
|
||||||
0, // use default stack size
|
QueueUserWorkItem(thread_callback, tr, WT_EXECUTELONGFUNCTION);
|
||||||
thread_callback, // thread function name
|
|
||||||
tr, // argument to thread function
|
|
||||||
0, // use default creation flags
|
|
||||||
NULL); // returns the thread identifier
|
|
||||||
|
|
||||||
return tr;
|
return tr;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user