JD2022-TU1/main/extern/Raki/Source/RakiTests/_PS3/System/RakiThread.cpp

58 lines
961 B
C++

#include "Precompiled.h"
#include <sys/ppu_thread.h>
#include <sys/timer.h>
#include "RakiEngine/System/RakiThread.h"
#include "RakiEngine/System/ThreadBase/ThreadBase.h"
namespace raki
{
static void RakiThread_Function( uint64_t _data )
{
RAKI_ASSERT( _data );
ThreadBase * object = (ThreadBase*) _data;
Thread::theThread( object );
}
void Thread::theThread( ThreadBase * _object )
{
RAKI_OUTPUT( "Thread::theThread launching thread on Thread 0x%x", _object );
_object->internalRun();
sys_ppu_thread_exit( 0 );
}
bool Thread::beginThread( ThreadBase * _object )
{
const int stackSize = 65536;
sys_ppu_thread_t result = 0;
int nRet = sys_ppu_thread_create(&result, RakiThread_Function, (u64)_object, 0, stackSize, SYS_PPU_THREAD_CREATE_JOINABLE, "MultiStream PU Thread");
return ( nRet == CELL_OK );
}
void Thread::sleep( u32 _milliseconds )
{
sys_timer_usleep( _milliseconds * 1000 );
}
}