diff --git a/src/Nazara/Platform/X11/WindowImpl.cpp b/src/Nazara/Platform/X11/WindowImpl.cpp index abf2db675..caf9ebd60 100644 --- a/src/Nazara/Platform/X11/WindowImpl.cpp +++ b/src/Nazara/Platform/X11/WindowImpl.cpp @@ -165,15 +165,14 @@ namespace Nz if (m_style & WindowStyle_Threaded) { - Mutex mutex; - ConditionVariable condition; + std::mutex mutex; + std::condition_variable condition; m_threadActive = true; // Wait until the thread is ready - mutex.Lock(); - m_thread = Thread(WindowThread, this, &mutex, &condition); - condition.Wait(&mutex); - mutex.Unlock(); + std::unique_lock lock(mutex); + m_thread = std::string(WindowThread, this, std::ref(mutex), std::ref(condition)); + condition.wait(lock); } // Set fullscreen video mode and switch to fullscreen if necessary @@ -1577,11 +1576,12 @@ namespace Nz )); } - void WindowImpl::WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition) + void WindowImpl::WindowThread(WindowImpl* window, std::mutex& mutex, std::condition_variable& condition) { - mutex->Lock(); - condition->Signal(); - mutex->Unlock(); // mutex and condition may be destroyed after this line + { + std::lock_guard lock(mutex); + condition.notify_all(); + } if (!window->m_window) return; diff --git a/src/Nazara/Platform/X11/WindowImpl.hpp b/src/Nazara/Platform/X11/WindowImpl.hpp index ecf5e0233..16509b9e5 100644 --- a/src/Nazara/Platform/X11/WindowImpl.hpp +++ b/src/Nazara/Platform/X11/WindowImpl.hpp @@ -10,18 +10,18 @@ #define NAZARA_WINDOWIMPL_HPP #include -#include #include #include #include #include +#include +#include +#include #include #include namespace Nz { - class ConditionVariable; - class Mutex; class Cursor; class Icon; class VideoMode; @@ -100,13 +100,13 @@ namespace Nz bool UpdateNormalHints(); void UpdateEventQueue(xcb_generic_event_t* event); - static void WindowThread(WindowImpl* window, Mutex* mutex, ConditionVariable* condition); + static void WindowThread(WindowImpl* window, std::mutex& mutex, std::condition_variable& condition); xcb_window_t m_window; xcb_screen_t* m_screen; xcb_randr_get_screen_info_reply_t m_oldVideoMode; xcb_size_hints_t m_size_hints; - Thread m_thread; + std::thread m_thread; WindowStyleFlags m_style; Window* m_parent; bool m_eventListener;