Remove processor dependency on XThread for breakpoints
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#ifndef XENIA_BASE_THREADING_H_
|
||||
#define XENIA_BASE_THREADING_H_
|
||||
|
||||
#include <algorithm>
|
||||
#include <atomic>
|
||||
#include <chrono>
|
||||
#include <climits>
|
||||
@@ -344,6 +345,7 @@ class Thread : public WaitHandle {
|
||||
// within that thread.
|
||||
static std::unique_ptr<Thread> Create(CreationParameters params,
|
||||
std::function<void()> start_routine);
|
||||
static std::unique_ptr<Thread> GetCurrentThread();
|
||||
|
||||
// Ends the calling thread.
|
||||
// No destructors are called, and this function does not return.
|
||||
|
||||
@@ -442,7 +442,7 @@ std::unique_ptr<Thread> Thread::Create(CreationParameters params,
|
||||
HANDLE handle =
|
||||
CreateThread(NULL, params.stack_size, ThreadStartRoutine, start_data,
|
||||
params.create_suspended ? CREATE_SUSPENDED : 0, NULL);
|
||||
if (!handle) {
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
// TODO(benvanik): pass back?
|
||||
auto last_error = GetLastError();
|
||||
XELOGE("Unable to CreateThread: %d", last_error);
|
||||
@@ -453,6 +453,15 @@ std::unique_ptr<Thread> Thread::Create(CreationParameters params,
|
||||
return std::make_unique<Win32Thread>(handle);
|
||||
}
|
||||
|
||||
std::unique_ptr<Thread> Thread::GetCurrentThread() {
|
||||
HANDLE handle = ::GetCurrentThread();
|
||||
if (handle == INVALID_HANDLE_VALUE) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return std::make_unique<Win32Thread>(handle);
|
||||
}
|
||||
|
||||
void Thread::Exit(int exit_code) { ExitThread(exit_code); }
|
||||
|
||||
} // namespace threading
|
||||
|
||||
Reference in New Issue
Block a user