Add threadlock and universal fs functions
This commit is contained in:
@@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user