AuroraRuntime/Source/Threading/Threads/AuThreads.cpp

33 lines
718 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) 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)
{
thread->Exit();
}
2021-09-06 10:58:08 +00:00
}
2021-06-27 21:25:29 +00:00
}