Merge pull request #364 from DrChat/xthread_name_id
Include host ID in XThread names
This commit is contained in:
commit
8936cfae70
|
@ -343,6 +343,9 @@ class Thread : public WaitHandle {
|
|||
// threads that had been waiting for the thread to terminate.
|
||||
static void Exit(int exit_code);
|
||||
|
||||
// Returns the ID of the thread
|
||||
virtual uint32_t id() const = 0;
|
||||
|
||||
// Returns the current name of the thread, if previously specified.
|
||||
std::string name() const { return name_; }
|
||||
|
||||
|
|
|
@ -358,6 +358,7 @@ class Win32Thread : public Win32Handle<Thread> {
|
|||
}
|
||||
|
||||
int32_t priority() override { return GetThreadPriority(handle_); }
|
||||
uint32_t id() const override { return GetThreadId(handle_); }
|
||||
|
||||
void set_priority(int32_t new_priority) override {
|
||||
SetThreadPriority(handle_, new_priority);
|
||||
|
|
|
@ -62,10 +62,6 @@ XThread::XThread(KernelState* kernel_state, uint32_t stack_size,
|
|||
|
||||
apc_list_ = new NativeList(kernel_state->memory());
|
||||
|
||||
char thread_name[32];
|
||||
snprintf(thread_name, xe::countof(thread_name), "XThread%04X", handle());
|
||||
set_name(thread_name);
|
||||
|
||||
// The kernel does not take a reference. We must unregister in the dtor.
|
||||
kernel_state_->RegisterThread(this);
|
||||
}
|
||||
|
@ -92,6 +88,7 @@ XThread::~XThread() {
|
|||
}
|
||||
|
||||
bool XThread::IsInThread(XThread* other) { return current_thread_tls == other; }
|
||||
bool XThread::IsInThread() { return current_thread_tls != nullptr; }
|
||||
|
||||
XThread* XThread::GetCurrentThread() {
|
||||
XThread* thread = current_thread_tls;
|
||||
|
@ -322,6 +319,11 @@ X_STATUS XThread::Create() {
|
|||
}
|
||||
thread_->set_affinity_mask(proc_mask);
|
||||
|
||||
// Set the thread name based on host ID (for easier debugging)
|
||||
char thread_name[32];
|
||||
snprintf(thread_name, xe::countof(thread_name), "XThread%04X (%04X)", handle(), thread_->id());
|
||||
set_name(thread_name);
|
||||
|
||||
if (creation_params_.creation_flags & 0x60) {
|
||||
thread_->set_priority(creation_params_.creation_flags & 0x20 ? 1 : 0);
|
||||
}
|
||||
|
|
|
@ -103,6 +103,7 @@ class XThread : public XObject {
|
|||
virtual ~XThread();
|
||||
|
||||
static bool IsInThread(XThread* other);
|
||||
static bool IsInThread();
|
||||
static XThread* GetCurrentThread();
|
||||
static uint32_t GetCurrentThreadHandle();
|
||||
static uint32_t GetCurrentThreadId();
|
||||
|
|
Loading…
Reference in New Issue