Files
dl_old/dl/system/dl_thread.cpp
T
2025-02-23 01:14:08 +08:00

34 lines
516 B
C++

#include "dl_thread.h"
#if DL_PLATFORM == DL_PLATFORM_WIN32
#include <Windows.h>
#endif
namespace dl
{
ThreadManager* g_thread;
void Thread::Terminate()
{
#if DL_PLATFORM == DL_PLATFORM_WIN32
TerminateThread(_t.native_handle(), -1);
#else
pthread_cancel(_t.native_handle());
#endif
_state = 1;
}
Thread::~Thread()
{
if (_t.joinable())
_t.join();
while (true)
{
if (_state != 0)
break;
std::this_thread::sleep_for(std::chrono::seconds(0));
}
g_thread->_remove_ref(this);
}
}