AuroraRuntime/Source/Threading/Threads/AuThreads.cpp

38 lines
787 B
C++
Raw Normal View History

2021-06-27 21:25:29 +00:00
/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
2022-11-17 07:46:07 +00:00
File: AuThreads.cpp
2021-06-27 21:25:29 +00:00
Date: 2021-6-21
Author: Reece
***/
2021-09-30 14:57:41 +00:00
#include <Source/RuntimeInternal.hpp>
2022-11-17 07:46:07 +00:00
#include "AuThreads.hpp"
#include "AuOSThread.hpp"
2021-06-27 21:25:29 +00:00
namespace Aurora::Threading::Threads
{
2021-09-06 10:58:08 +00:00
AUKN_SYM IAuroraThread *ThreadNew(const ThreadInfo &info)
2021-06-27 21:25:29 +00:00
{
if (!info.callbacks)
{
SysPushErrorArg();
return {};
}
2021-09-06 10:58:08 +00:00
return _new OSThread(info);
2021-06-27 21:25:29 +00:00
}
2022-11-17 07:46:07 +00:00
AUKN_SYM void ThreadRelease(IAuroraThread *pThread)
2021-06-27 21:25:29 +00:00
{
2022-11-17 07:46:07 +00:00
AuSafeDelete<OSThread *>(pThread);
2021-06-27 21:25:29 +00:00
}
2021-09-06 10:58:08 +00:00
AUKN_SYM void TerminateCurrent()
{
auto thread = GetThread();
if (thread && gRuntimeRunLevel < 4)
{
2024-05-27 12:26:20 +00:00
thread->Terminate();
}
2021-09-06 10:58:08 +00:00
}
2021-06-27 21:25:29 +00:00
}