Add all the files

This commit is contained in:
Exzap 2022-08-22 22:21:23 +02:00
parent e3db07a16a
commit d60742f52b
1445 changed files with 430238 additions and 0 deletions

View file

@ -0,0 +1,68 @@
#pragma once
#include <mutex>
#include <condition_variable>
#include <queue>
#include "Cafe/OS/libs/coreinit/coreinit_Thread.h"
template <typename T>
class PPCConcurrentQueue
{
public:
PPCConcurrentQueue() {}
PPCConcurrentQueue(const PPCConcurrentQueue&) = delete;
PPCConcurrentQueue& operator=(const PPCConcurrentQueue&) = delete;
void push(const T& item, OSThread_t* thread)
{
//if(thread == nullptr)
// thread = coreinitThread_getCurrentThread(ppcInterpreterCurrentInstance);
//OSThread_t* currentThread = coreinit::OSGetCurrentThread();
//cemu_assert_debug(thread == nullptr || currentThread == thread);
// forceLogDebug_printf("push suspend count: %d", _swapEndianU32(thread->suspend) - m_suspendCount);
//__OSLockScheduler();
__OSLockScheduler();
m_queue.push(item);
coreinit::__OSResumeThreadInternal(thread, 1);
__OSUnlockScheduler();
//__OSUnlockScheduler();
//m_prevSuspendCount = _swapEndianU32(thread->suspend) - m_suspendCount;
//coreinit_resumeThread(thread, _swapEndianU32(thread->suspend));
}
T pop(OSThread_t* thread = nullptr)
{
//if (thread == nullptr)
// thread = coreinitThread_getCurrentThread(ppcInterpreterCurrentInstance);
OSThread_t* currentThread = coreinit::OSGetCurrentThread();
cemu_assert_debug(thread == nullptr || currentThread == thread);
//thread = coreinitThread_getCurrentThread(ppcInterpreterCurrentInstance);
// forceLogDebug_printf("pop suspend count: %d", _swapEndianU32(thread->suspend) + m_suspendCount);
__OSLockScheduler();
if (m_queue.empty())
coreinit::__OSSuspendThreadInternal(thread);
auto val = m_queue.front();
m_queue.pop();
__OSUnlockScheduler();
//coreinit_suspendThread(thread, m_suspendCount + m_prevSuspendCount);
//m_prevSuspendCount = 0;
//PPCCore_switchToScheduler();
return val;
}
private:
//const int m_suspendCount = 8000;
std::queue<T> m_queue;
//std::atomic<uint32> m_prevSuspendCount;
};