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: AuGrugThread.cpp
|
|
Date: 2022-02-03
|
|
Author: Reece
|
|
***/
|
|
#include <Source/RuntimeInternal.hpp>
|
|
#include "AuGrug.hpp"
|
|
#include "AuGrugThread.hpp"
|
|
|
|
#include <Source/Threading/Threads/AuThreadHandles.hpp>
|
|
|
|
namespace Aurora::Grug
|
|
{
|
|
GrugThread::GrugThread()
|
|
{
|
|
#if defined(AURORA_IS_MODERNNT_DERIVED)
|
|
nt.pThread = AuThreads::GetThread(); // not signal 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);
|
|
}
|
|
} |