From 782702fe748e404f65864bd9c2df27f7483f9450 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 10 Jun 2025 21:36:23 -0400 Subject: [PATCH] refactor: use std::mutex in platform/XWindowsEventQueue --- src/lib/platform/XWindowsEventQueueBuffer.cpp | 13 ++++++------- src/lib/platform/XWindowsEventQueueBuffer.h | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/lib/platform/XWindowsEventQueueBuffer.cpp b/src/lib/platform/XWindowsEventQueueBuffer.cpp index 23111572b..2aac50238 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.cpp +++ b/src/lib/platform/XWindowsEventQueueBuffer.cpp @@ -9,7 +9,6 @@ #include "base/Event.h" #include "base/IEventQueue.h" -#include "mt/Lock.h" #include "mt/Thread.h" #include @@ -51,7 +50,7 @@ XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer() int XWindowsEventQueueBuffer::getPendingCountLocked() { - Lock lock(&m_mutex); + std::lock_guard lock(m_mutex); return XPending(m_display); } @@ -69,7 +68,7 @@ void XWindowsEventQueueBuffer::waitForEvent(double dtimeout) } { - Lock lock(&m_mutex); + std::lock_guard lock(m_mutex); // we're now waiting for events m_waiting = true; @@ -123,7 +122,7 @@ void XWindowsEventQueueBuffer::waitForEvent(double dtimeout) { // we're no longer waiting for events - Lock lock(&m_mutex); + std::lock_guard lock(m_mutex); m_waiting = false; } @@ -132,7 +131,7 @@ void XWindowsEventQueueBuffer::waitForEvent(double dtimeout) IEventQueueBuffer::Type XWindowsEventQueueBuffer::getEvent(Event &event, uint32_t &dataID) { - Lock lock(&m_mutex); + std::lock_guard lock(m_mutex); // push out pending events flush(); @@ -161,7 +160,7 @@ bool XWindowsEventQueueBuffer::addEvent(uint32_t dataID) xevent.xclient.data.l[0] = static_cast(dataID); // save the message - Lock lock(&m_mutex); + std::lock_guard lock(m_mutex); m_postedEvents.push_back(xevent); // if we're currently waiting for an event then send saved events to @@ -187,7 +186,7 @@ bool XWindowsEventQueueBuffer::addEvent(uint32_t dataID) bool XWindowsEventQueueBuffer::isEmpty() const { - Lock lock(&m_mutex); + std::lock_guard lock(m_mutex); return (XPending(m_display) == 0); } diff --git a/src/lib/platform/XWindowsEventQueueBuffer.h b/src/lib/platform/XWindowsEventQueueBuffer.h index 477890557..4c482c7a9 100644 --- a/src/lib/platform/XWindowsEventQueueBuffer.h +++ b/src/lib/platform/XWindowsEventQueueBuffer.h @@ -8,8 +8,8 @@ #pragma once #include "base/IEventQueueBuffer.h" -#include "mt/Mutex.h" +#include #include #include @@ -47,7 +47,7 @@ private: private: using EventList = std::vector; - Mutex m_mutex; + mutable std::mutex m_mutex; Display *m_display; Window m_window; Atom m_userEvent;