[+] AuThreads::Spawn
This commit is contained in:
parent
7efde62c3c
commit
d123850ac0
40
Include/Aurora/Threading/Threads/Spawn.hpp
Normal file
40
Include/Aurora/Threading/Threads/Spawn.hpp
Normal file
@ -0,0 +1,40 @@
|
||||
/***
|
||||
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
|
||||
|
||||
File: Spawn.hpp
|
||||
Date: 2023-09-20
|
||||
Author: Reece
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
namespace Aurora::Threading::Threads
|
||||
{
|
||||
static ThreadUnique_t Spawn(AuVoidFunc entrypoint,
|
||||
bool bDetached = false,
|
||||
AuUInt32 uStackSize = 0)
|
||||
{
|
||||
auto thread = ThreadUnique(ThreadInfo(
|
||||
AuMakeShared<IThreadVectorsFunctional>(IThreadVectorsFunctional::OnEntry_t(std::bind(entrypoint)), IThreadVectorsFunctional::OnExit_t {}),
|
||||
uStackSize
|
||||
));
|
||||
|
||||
if (!thread)
|
||||
{
|
||||
SysPushErrorNested();
|
||||
return ThreadUnique_t {};
|
||||
}
|
||||
|
||||
if (!thread->Run())
|
||||
{
|
||||
SysPushErrorNested();
|
||||
return ThreadUnique_t {};
|
||||
}
|
||||
|
||||
if (bDetached)
|
||||
{
|
||||
thread->Detach();
|
||||
}
|
||||
|
||||
return AuMove(thread);
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@
|
||||
#include "IAuroraThread.hpp"
|
||||
#include "ThreadInfo.hpp"
|
||||
#include "Thread.hpp"
|
||||
#include "Spawn.hpp"
|
||||
#include "TLSView.hpp"
|
||||
#include "TLSVariable.hpp"
|
||||
#include "TLSStaticVariable.hpp"
|
Loading…
Reference in New Issue
Block a user