54 lines
1.2 KiB
C++
54 lines
1.2 KiB
C++
|
/***
|
||
|
Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||
|
|
||
|
File: GrugThread.cpp
|
||
|
Date: 2022-02-03
|
||
|
Author: Reece
|
||
|
***/
|
||
|
#include <Source/RuntimeInternal.hpp>
|
||
|
#include "Grug.hpp"
|
||
|
#include "GrugThread.hpp"
|
||
|
|
||
|
#include <Source/Threading/Threads/ThreadHandles.hpp>
|
||
|
|
||
|
namespace Aurora::Grug
|
||
|
{
|
||
|
GrugThread::GrugThread()
|
||
|
{
|
||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||
|
nt.pThread = AuThreads::GetThread(); // not thread async safe, but we arent in posix land
|
||
|
#endif
|
||
|
|
||
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
||
|
// idnt by active ttid only
|
||
|
posix.pid = gettid();
|
||
|
#else
|
||
|
// posix signal rules dont apply
|
||
|
genericThreadHandle = AuThreads::GetThreadId();
|
||
|
#endif
|
||
|
|
||
|
}
|
||
|
|
||
|
AuThreads::IAuroraThread *GrugThread::ToThread() const
|
||
|
{
|
||
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
||
|
if (nt.pThread)
|
||
|
{
|
||
|
return nt.pThread;
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
#if defined(AURORA_IS_POSIX_DERIVED)
|
||
|
if (posix.pid >= 0)
|
||
|
{
|
||
|
auto pThread = AuThreads::GetThreadByPOSIXPid(posix.pid);
|
||
|
if (pThread)
|
||
|
{
|
||
|
return pThread;
|
||
|
}
|
||
|
}
|
||
|
#endif
|
||
|
|
||
|
return AuThreads::GetThreadByOSHandle(genericThreadHandle);
|
||
|
}
|
||
|
}
|