XThread Terminate
This commit is contained in:
parent
7f53b1d630
commit
778acac929
|
@ -337,6 +337,8 @@ X_STATUS XThread::Create() {
|
|||
}
|
||||
|
||||
X_STATUS XThread::Exit(int exit_code) {
|
||||
assert_true(XThread::GetCurrentThread() == this);
|
||||
|
||||
// TODO(benvanik): set exit code in thread state block
|
||||
|
||||
// TODO(benvanik); dispatch events? waiters? etc?
|
||||
|
@ -359,6 +361,21 @@ X_STATUS XThread::Exit(int exit_code) {
|
|||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS XThread::Terminate(int exit_code) {
|
||||
if (event_) {
|
||||
event_->Set(0, false);
|
||||
}
|
||||
// TODO: Inform the profiler that this thread is exiting.
|
||||
|
||||
Release();
|
||||
X_STATUS status = PlatformTerminate(exit_code);
|
||||
if (XFAILED(status)) {
|
||||
return status;
|
||||
}
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#if XE_PLATFORM_WIN32
|
||||
|
||||
static uint32_t __stdcall XThreadStartCallbackWin32(void* param) {
|
||||
|
@ -406,6 +423,14 @@ X_STATUS XThread::PlatformExit(int exit_code) {
|
|||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS XThread::PlatformTerminate(int exit_code) {
|
||||
if (!TerminateThread(thread_handle_, exit_code)) {
|
||||
return X_STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
|
||||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
static void* XThreadStartCallbackPthreads(void* param) {
|
||||
|
@ -465,6 +490,11 @@ X_STATUS XThread::PlatformExit(int exit_code) {
|
|||
return X_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
X_STATUS XThread::PlatformTerminate(int exit_code) {
|
||||
// TODO!
|
||||
assert_always();
|
||||
}
|
||||
|
||||
#endif // WIN32
|
||||
|
||||
void XThread::Execute() {
|
||||
|
|
|
@ -103,6 +103,7 @@ class XThread : public XObject {
|
|||
|
||||
X_STATUS Create();
|
||||
X_STATUS Exit(int exit_code);
|
||||
X_STATUS Terminate(int exit_code);
|
||||
|
||||
virtual void Execute();
|
||||
|
||||
|
@ -137,6 +138,7 @@ class XThread : public XObject {
|
|||
X_STATUS PlatformCreate();
|
||||
void PlatformDestroy();
|
||||
X_STATUS PlatformExit(int exit_code);
|
||||
X_STATUS PlatformTerminate(int exit_code);
|
||||
|
||||
static void DeliverAPCs(void* data);
|
||||
void RundownAPCs();
|
||||
|
|
Loading…
Reference in New Issue