diff options
author | RĂ©mi Verschelde <remi@verschelde.fr> | 2021-01-31 15:24:56 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-31 15:24:56 +0100 |
commit | 5525cd85c60455b0bb9716bbef0ad2ad8111d752 (patch) | |
tree | 52ff0e2d3e01dd2655feff1cf88f07e10d84aad1 /platform/linuxbsd | |
parent | 02eb11450b4151b02db861b5029783e52e16c603 (diff) | |
parent | 99fe462452be44efa618e83ad9bbecd722ae6ecd (diff) |
Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
Diffstat (limited to 'platform/linuxbsd')
-rw-r--r-- | platform/linuxbsd/display_server_x11.cpp | 6 | ||||
-rw-r--r-- | platform/linuxbsd/display_server_x11.h | 2 | ||||
-rw-r--r-- | platform/linuxbsd/joypad_linux.cpp | 5 | ||||
-rw-r--r-- | platform/linuxbsd/joypad_linux.h | 2 |
4 files changed, 6 insertions, 9 deletions
diff --git a/platform/linuxbsd/display_server_x11.cpp b/platform/linuxbsd/display_server_x11.cpp index 3f1a7ced60..53baf17858 100644 --- a/platform/linuxbsd/display_server_x11.cpp +++ b/platform/linuxbsd/display_server_x11.cpp @@ -4266,7 +4266,7 @@ DisplayServerX11::DisplayServerX11(const String &p_rendering_driver, WindowMode } } - events_thread = Thread::create(_poll_events_thread, this); + events_thread.start(_poll_events_thread, this); _update_real_mouse_position(windows[MAIN_WINDOW_ID]); @@ -4280,9 +4280,7 @@ DisplayServerX11::~DisplayServerX11() { _clipboard_transfer_ownership(XInternAtom(x11_display, "CLIPBOARD", 0), x11_main_window); events_thread_done = true; - Thread::wait_to_finish(events_thread); - memdelete(events_thread); - events_thread = nullptr; + events_thread.wait_to_finish(); //destroy all windows for (Map<WindowID, WindowData>::Element *E = windows.front(); E; E = E->next()) { diff --git a/platform/linuxbsd/display_server_x11.h b/platform/linuxbsd/display_server_x11.h index 7784ba82b5..906710f933 100644 --- a/platform/linuxbsd/display_server_x11.h +++ b/platform/linuxbsd/display_server_x11.h @@ -252,7 +252,7 @@ class DisplayServerX11 : public DisplayServer { void _dispatch_input_event(const Ref<InputEvent> &p_event); mutable Mutex events_mutex; - Thread *events_thread = nullptr; + Thread events_thread; bool events_thread_done = false; LocalVector<XEvent> polled_events; static void _poll_events_thread(void *ud); diff --git a/platform/linuxbsd/joypad_linux.cpp b/platform/linuxbsd/joypad_linux.cpp index d54d805199..4e96e6d687 100644 --- a/platform/linuxbsd/joypad_linux.cpp +++ b/platform/linuxbsd/joypad_linux.cpp @@ -74,13 +74,12 @@ void JoypadLinux::Joypad::reset() { JoypadLinux::JoypadLinux(Input *in) { exit_udev = false; input = in; - joy_thread = Thread::create(joy_thread_func, this); + joy_thread.start(joy_thread_func, this); } JoypadLinux::~JoypadLinux() { exit_udev = true; - Thread::wait_to_finish(joy_thread); - memdelete(joy_thread); + joy_thread.wait_to_finish(); close_joypad(); } diff --git a/platform/linuxbsd/joypad_linux.h b/platform/linuxbsd/joypad_linux.h index 20d30b510c..bf343b7ceb 100644 --- a/platform/linuxbsd/joypad_linux.h +++ b/platform/linuxbsd/joypad_linux.h @@ -72,7 +72,7 @@ private: bool exit_udev; Mutex joy_mutex; - Thread *joy_thread; + Thread joy_thread; Input *input; Joypad joypads[JOYPADS_MAX]; Vector<String> attached_devices; |