44 lines
1.1 KiB
C++
44 lines
1.1 KiB
C++
|
|
#include "Precompiled.h"
|
|
#include "RakiEngine/System/RakiThread.h"
|
|
#include "RakiEngine/System/ThreadBase/ThreadBase.h"
|
|
|
|
namespace raki
|
|
{
|
|
void* RakiThread_Function(void* _data)
|
|
{
|
|
RAKI_ASSERT(_data);
|
|
auto* object = reinterpret_cast<ThreadBase*>(_data);
|
|
Thread::theThread(object);
|
|
return nullptr;
|
|
}
|
|
|
|
void Thread::theThread(ThreadBase* _object)
|
|
{
|
|
RAKI_OUTPUT( "Thread::theThread launching thread on Thread 0x%x", _object );
|
|
_object->internalRun();
|
|
}
|
|
|
|
bool Thread::beginThread(ThreadBase* _object)
|
|
{
|
|
ScePthread thread;
|
|
ScePthreadAttr threadAttributes;
|
|
|
|
int result = scePthreadAttrInit(&threadAttributes);
|
|
RAKI_ASSERT(result == SCE_OK);
|
|
result = scePthreadCreate(&thread,
|
|
&threadAttributes,
|
|
RakiThread_Function,
|
|
_object,
|
|
nullptr);
|
|
RAKI_ASSERT(result == SCE_OK);
|
|
scePthreadAttrDestroy(&threadAttributes);
|
|
return thread != nullptr;
|
|
}
|
|
|
|
void Thread::sleep(u32 _millisecond)
|
|
{
|
|
sceKernelUsleep(_millisecond * 1000);
|
|
}
|
|
}
|
|
|