mirror of
https://github.com/tiennm99/godot.git
synced 2026-08-18 08:25:04 +00:00
Modernize Semaphore
- Based on C++11's `mutex` and `condition_variable` - No more need to allocate-deallocate or check for null - No pointer anymore, just a member variable - Platform-specific implementations no longer needed - Simpler for `NO_THREADS`
This commit is contained in:
@@ -2711,7 +2711,7 @@ void VisualServerScene::_gi_probe_bake_thread() {
|
||||
|
||||
while (true) {
|
||||
|
||||
probe_bake_sem->wait();
|
||||
probe_bake_sem.wait();
|
||||
if (probe_bake_thread_exit) {
|
||||
break;
|
||||
}
|
||||
@@ -3410,7 +3410,7 @@ void VisualServerScene::render_probes() {
|
||||
probe->dynamic.updating_stage = GI_UPDATE_STAGE_LIGHTING;
|
||||
probe_bake_list.push_back(instance_probe);
|
||||
probe_bake_mutex.unlock();
|
||||
probe_bake_sem->post();
|
||||
probe_bake_sem.post();
|
||||
|
||||
#else
|
||||
|
||||
@@ -3683,7 +3683,6 @@ VisualServerScene *VisualServerScene::singleton = NULL;
|
||||
VisualServerScene::VisualServerScene() {
|
||||
|
||||
#ifndef NO_THREADS
|
||||
probe_bake_sem = Semaphore::create();
|
||||
probe_bake_thread = Thread::create(_gi_probe_bake_threads, this);
|
||||
probe_bake_thread_exit = false;
|
||||
#endif
|
||||
@@ -3697,9 +3696,8 @@ VisualServerScene::~VisualServerScene() {
|
||||
|
||||
#ifndef NO_THREADS
|
||||
probe_bake_thread_exit = true;
|
||||
probe_bake_sem->post();
|
||||
probe_bake_sem.post();
|
||||
Thread::wait_to_finish(probe_bake_thread);
|
||||
memdelete(probe_bake_thread);
|
||||
memdelete(probe_bake_sem);
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user