[+] IAuroraThread::GetThreadCreationTime
This commit is contained in:
parent
be60d2c80d
commit
529eba18c7
@ -17,6 +17,8 @@ namespace Aurora::HWInfo
|
|||||||
struct CpuBitId;
|
struct CpuBitId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include <Aurora/Time/EClock.hpp>
|
||||||
|
|
||||||
namespace Aurora::Threading::Threads
|
namespace Aurora::Threading::Threads
|
||||||
{
|
{
|
||||||
struct TLSView;
|
struct TLSView;
|
||||||
@ -52,6 +54,11 @@ namespace Aurora::Threading::Threads
|
|||||||
virtual HWInfo::CpuBitId GetMask() = 0;
|
virtual HWInfo::CpuBitId GetMask() = 0;
|
||||||
virtual AuString GetName() = 0;
|
virtual AuString GetName() = 0;
|
||||||
|
|
||||||
|
|
||||||
|
virtual AuUInt64 GetThreadCreationTime(Time::EClock eClock) = 0;
|
||||||
|
|
||||||
|
// TODO: will deprecate with a version that does call init on thread and deinit on deinit
|
||||||
|
// ... just wait for it
|
||||||
/// Registers a thread feature _not_ calling on init
|
/// Registers a thread feature _not_ calling on init
|
||||||
/// It is not possible for this lower level thread object to schedule an init call (defer to async)
|
/// It is not possible for this lower level thread object to schedule an init call (defer to async)
|
||||||
/// Use this to register teardown functions
|
/// Use this to register teardown functions
|
||||||
|
@ -90,6 +90,8 @@ namespace Aurora::Threading::Threads
|
|||||||
this->terminateSignal_ = AuThreadPrimitives::EventShared(true, false, true);
|
this->terminateSignal_ = AuThreadPrimitives::EventShared(true, false, true);
|
||||||
|
|
||||||
SysAssert(this->terminatedSignalLs_ && this->terminateSignalLs_ && this->terminated_ && this->terminateSignal_);
|
SysAssert(this->terminatedSignalLs_ && this->terminateSignalLs_ && this->terminated_ && this->terminateSignal_);
|
||||||
|
|
||||||
|
this->InitThreadCreateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
OSThread::OSThread() : info_(gDummyThreadInfo),
|
OSThread::OSThread() : info_(gDummyThreadInfo),
|
||||||
@ -102,6 +104,8 @@ namespace Aurora::Threading::Threads
|
|||||||
|
|
||||||
SysAssert(this->terminated_ && this->terminateSignal_);
|
SysAssert(this->terminated_ && this->terminateSignal_);
|
||||||
this->bNotOwned = true;
|
this->bNotOwned = true;
|
||||||
|
|
||||||
|
this->InitThreadCreateTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
OSThread::OSThread(AuUInt64 id) : info_(gDummyThreadInfo),
|
OSThread::OSThread(AuUInt64 id) : info_(gDummyThreadInfo),
|
||||||
@ -551,6 +555,32 @@ namespace Aurora::Threading::Threads
|
|||||||
|
|
||||||
void AttachSignalKiller();
|
void AttachSignalKiller();
|
||||||
|
|
||||||
|
void OSThread::InitThreadCreateTime()
|
||||||
|
{
|
||||||
|
uClockCreationTime[0] = AuTime::CurrentClockNS();
|
||||||
|
uClockCreationTime[1] = AuTime::SteadyClockNS();
|
||||||
|
}
|
||||||
|
|
||||||
|
AuUInt64 OSThread::GetThreadCreationTime(Time::EClock eClock)
|
||||||
|
{
|
||||||
|
if (AuTime::EClockIsValid(eClock))
|
||||||
|
{
|
||||||
|
SysPushErrorArg();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (eClock)
|
||||||
|
{
|
||||||
|
case Time::EClock::eWall:
|
||||||
|
return uClockCreationTime[0];
|
||||||
|
case Time::EClock::eSteady:
|
||||||
|
return uClockCreationTime[1];
|
||||||
|
default:
|
||||||
|
SysPushErrorArg();
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void OSThread::_ThreadEP()
|
void OSThread::_ThreadEP()
|
||||||
{
|
{
|
||||||
// Poke TLS reference thread entity
|
// Poke TLS reference thread entity
|
||||||
@ -577,6 +607,8 @@ namespace Aurora::Threading::Threads
|
|||||||
auto pA = this->terminatedSignalLs_;
|
auto pA = this->terminatedSignalLs_;
|
||||||
auto pB = this->terminated_;
|
auto pB = this->terminated_;
|
||||||
|
|
||||||
|
this->InitThreadCreateTime();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (auto task = task_)
|
if (auto task = task_)
|
||||||
|
@ -47,6 +47,10 @@ namespace Aurora::Threading::Threads
|
|||||||
|
|
||||||
void Detach() override;
|
void Detach() override;
|
||||||
|
|
||||||
|
AuUInt64 GetThreadCreationTime(Time::EClock eClock) override;
|
||||||
|
|
||||||
|
void InitThreadCreateTime();
|
||||||
|
|
||||||
void _ThreadEP();
|
void _ThreadEP();
|
||||||
AuSPtr<AuLoop::ILoopSource> AsLoopSource() override;
|
AuSPtr<AuLoop::ILoopSource> AsLoopSource() override;
|
||||||
AuSPtr<IWaitable> GetShutdownSignalWaitable() override;
|
AuSPtr<IWaitable> GetShutdownSignalWaitable() override;
|
||||||
@ -108,6 +112,7 @@ namespace Aurora::Threading::Threads
|
|||||||
Primitives::CriticalSection exitOnlyOnce_;
|
Primitives::CriticalSection exitOnlyOnce_;
|
||||||
AuList<AuSPtr<IThreadFeature>> threadFeatures_;
|
AuList<AuSPtr<IThreadFeature>> threadFeatures_;
|
||||||
AuBinarySemaphore epExecEvent;
|
AuBinarySemaphore epExecEvent;
|
||||||
|
AuUInt64 uClockCreationTime[2] {};
|
||||||
|
|
||||||
AuFunction<void()> task_;
|
AuFunction<void()> task_;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user