refactor: use std::mutex in platform/XWindowsEventQueue

This commit is contained in:
sithlord48 2025-06-10 21:36:23 -04:00 committed by Nick Bolton
parent 5686d24626
commit 782702fe74
2 changed files with 8 additions and 9 deletions

View file

@ -9,7 +9,6 @@
#include "base/Event.h"
#include "base/IEventQueue.h"
#include "mt/Lock.h"
#include "mt/Thread.h"
#include <fcntl.h>
@ -51,7 +50,7 @@ XWindowsEventQueueBuffer::~XWindowsEventQueueBuffer()
int XWindowsEventQueueBuffer::getPendingCountLocked()
{
Lock lock(&m_mutex);
std::lock_guard<std::mutex> lock(m_mutex);
return XPending(m_display);
}
@ -69,7 +68,7 @@ void XWindowsEventQueueBuffer::waitForEvent(double dtimeout)
}
{
Lock lock(&m_mutex);
std::lock_guard<std::mutex> 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<std::mutex> 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<std::mutex> 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<long>(dataID);
// save the message
Lock lock(&m_mutex);
std::lock_guard<std::mutex> 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<std::mutex> lock(m_mutex);
return (XPending(m_display) == 0);
}

View file

@ -8,8 +8,8 @@
#pragma once
#include "base/IEventQueueBuffer.h"
#include "mt/Mutex.h"
#include <mutex>
#include <vector>
#include <X11/Xlib.h>
@ -47,7 +47,7 @@ private:
private:
using EventList = std::vector<XEvent>;
Mutex m_mutex;
mutable std::mutex m_mutex;
Display *m_display;
Window m_window;
Atom m_userEvent;