Merge pull request #45315 from RandomShaper/modernize_thread
Modernize Thread
This commit is contained in:
commit
5525cd85c6
87 changed files with 385 additions and 1056 deletions
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue