mirror of
https://github.com/cemu-project/Cemu.git
synced 2025-12-29 16:37:03 +00:00
Add all the files
This commit is contained in:
parent
e3db07a16a
commit
d60742f52b
1445 changed files with 430238 additions and 0 deletions
68
src/Cafe/OS/common/PPCConcurrentQueue.h
Normal file
68
src/Cafe/OS/common/PPCConcurrentQueue.h
Normal 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;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue