Add threadlock and universal fs functions

This commit is contained in:
murdle
2026-03-01 23:19:08 +02:00
parent 53bd1b7e5b
commit 41ad19cd15
92 changed files with 618 additions and 281 deletions

View File

@@ -6,7 +6,6 @@
#include "SkinBox.h"
#include <vector>
#define MULTITHREAD_ENABLE
@@ -93,7 +92,7 @@ template <typename T>
class XLockFreeStack
{
std::vector<T*> intStack;
mutable std::mutex m_mutex;
mutable ThreadLock m_lock;
public:
XLockFreeStack() = default;
@@ -103,19 +102,22 @@ public:
void Push(T* data)
{
std::lock_guard<std::mutex> lock(m_mutex);
m_lock.lock();
intStack.push_back(data);
m_lock.unlock();
}
T* Pop()
{
std::lock_guard<std::mutex> lock(m_mutex);
m_lock.lock();
if (intStack.empty())
return nullptr;
T* ret = intStack.back();
intStack.pop_back();
m_lock.unlock();
return ret;
}
};