[+] Thread name identities

This commit is contained in:
Reece Wilson 2024-01-23 23:03:52 +00:00
parent cb751d0286
commit 7038787001
3 changed files with 19 additions and 5 deletions

View File

@ -48,18 +48,19 @@ namespace Aurora::Threading::Threads
virtual void SetThrottle(EThreadThrottle throttle) = 0;
virtual void SetAffinity(const HWInfo::CpuBitId &mask) = 0;
virtual void SetName(const AuString &name) = 0;
virtual void SetNameIdentity(AuUInt32 uNameIdentity) = 0;
virtual EThreadPriority GetPriority() = 0;
virtual EThreadThrottle GetThrottle() = 0;
virtual HWInfo::CpuBitId GetMask() = 0;
virtual AuString GetName() = 0;
virtual AuUInt32 GetNameIdentity() = 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
/// It is not possible for this lower level thread object to schedule an init call (defer to async)
/// Registers a thread feature _not_ calling on init [for now]
/// It is not possible for this lower level thread object to schedule an init call (defer to async) [for now]
/// Use this to register teardown functions
virtual void AddLastHopeTlsHook(const AuSPtr<Threading::Threads::IThreadFeature> &feature) = 0;

View File

@ -414,9 +414,15 @@ namespace Aurora::Threading::Threads
return;
}
this->name_ = name;
this->uNameIdentity_ = AuFnv1a32Runtime(name.data(), name.size());
this->UpdateName();
}
void OSThread::SetNameIdentity(AuUInt32 uNameIdentity)
{
this->uNameIdentity_ = uNameIdentity;
}
EThreadThrottle OSThread::GetThrottle()
{
return this->throttle_;
@ -437,6 +443,11 @@ namespace Aurora::Threading::Threads
return this->name_;
}
AuUInt32 OSThread::GetNameIdentity()
{
return this->uNameIdentity_;
}
void OSThread::SetAffinity(const HWInfo::CpuBitId &mask)
{
auto zero = HWInfo::CpuBitId();

View File

@ -31,11 +31,13 @@ namespace Aurora::Threading::Threads
void SetThrottle(EThreadThrottle prio) override;
void SetAffinity(const HWInfo::CpuBitId &mask) override;
void SetName(const AuString &name) override;
void SetNameIdentity(AuUInt32 uNameIdentity) override;
EThreadPriority GetPriority() override;
EThreadThrottle GetThrottle() override;
HWInfo::CpuBitId GetMask() override;
AuString GetName() override;
AuUInt32 GetNameIdentity() override;
void ExecuteInDeadThread(AuFunction<void()> callback) override;
AuSPtr<IWaitable> AsWaitable() override;
@ -122,7 +124,7 @@ namespace Aurora::Threading::Threads
AuUInt64 unixThreadId_ = 0;
bool detached_ {};
AuUInt32 uNameIdentity_ {};
};
void InitThreading();