From 99fe462452be44efa618e83ad9bbecd722ae6ecd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pedro=20J=2E=20Est=C3=A9banez?= Date: Tue, 19 Jan 2021 13:29:41 +0100 Subject: 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) --- editor/audio_stream_preview.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'editor/audio_stream_preview.cpp') diff --git a/editor/audio_stream_preview.cpp b/editor/audio_stream_preview.cpp index 2e0c3491f7..8be8735f3e 100644 --- a/editor/audio_stream_preview.cpp +++ b/editor/audio_stream_preview.cpp @@ -197,7 +197,8 @@ Ref AudioStreamPreviewGenerator::generate_preview(const Ref< preview->preview->length = len_s; if (preview->playback.is_valid()) { - preview->thread = Thread::create(_preview_thread, preview); + preview->thread = memnew(Thread); + preview->thread->start(_preview_thread, preview); } return preview->preview; @@ -218,7 +219,8 @@ void AudioStreamPreviewGenerator::_notification(int p_what) { for (Map::Element *E = previews.front(); E; E = E->next()) { if (!E->get().generating) { if (E->get().thread) { - Thread::wait_to_finish(E->get().thread); + E->get().thread->wait_to_finish(); + memdelete(E->get().thread); E->get().thread = nullptr; } if (!ObjectDB::get_instance(E->key())) { //no longer in use, get rid of preview -- cgit v1.2.3