mirror of
https://github.com/tiennm99/godot.git
synced 2026-08-05 04:22:10 +00:00
Modernize Thread
- Based on C++11's `thread` and `thread_local` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed (except for the few cases of non-portable functions) - Simpler for `NO_THREADS` - Thread ids are now the same across platforms (main is 1; others follow)
This commit is contained in:
@@ -97,7 +97,7 @@ void RenderingServerWrapMT::init() {
|
||||
print_verbose("RenderingServerWrapMT: Creating render thread");
|
||||
DisplayServer::get_singleton()->release_rendering_thread();
|
||||
if (create_thread) {
|
||||
thread = Thread::create(_thread_callback, this);
|
||||
thread.start(_thread_callback, this);
|
||||
print_verbose("RenderingServerWrapMT: Starting render thread");
|
||||
}
|
||||
while (!draw_thread_up) {
|
||||
@@ -136,12 +136,9 @@ void RenderingServerWrapMT::finish() {
|
||||
canvas_light_occluder_free_cached_ids();
|
||||
canvas_occluder_polygon_free_cached_ids();
|
||||
|
||||
if (thread) {
|
||||
if (create_thread) {
|
||||
command_queue.push(this, &RenderingServerWrapMT::thread_exit);
|
||||
Thread::wait_to_finish(thread);
|
||||
memdelete(thread);
|
||||
|
||||
thread = nullptr;
|
||||
thread.wait_to_finish();
|
||||
} else {
|
||||
rendering_server->finish();
|
||||
}
|
||||
@@ -160,7 +157,6 @@ RenderingServerWrapMT::RenderingServerWrapMT(RenderingServer *p_contained, bool
|
||||
|
||||
rendering_server = p_contained;
|
||||
create_thread = p_create_thread;
|
||||
thread = nullptr;
|
||||
draw_pending = 0;
|
||||
draw_thread_up = false;
|
||||
pool_max_size = GLOBAL_GET("memory/limits/multithreaded_server/rid_pool_prealloc");
|
||||
|
||||
Reference in New Issue
Block a user