mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
38 lines
885 B
C
38 lines
885 B
C
|
#pragma once
|
||
|
|
||
|
#include "Thread.h"
|
||
|
#include "ThreadStart.h"
|
||
|
|
||
|
namespace Threading
|
||
|
{
|
||
|
class Task
|
||
|
{
|
||
|
public:
|
||
|
// Starts the specified action on a new thread
|
||
|
inline static void Run(ThreadStart Action)
|
||
|
{
|
||
|
Thread(Action).Start();
|
||
|
}
|
||
|
// Starts the specified action on a new thread with the given object
|
||
|
inline static void Run(ParameterizedThreadStart Action, void* Object)
|
||
|
{
|
||
|
Thread(Action).Start(Object);
|
||
|
}
|
||
|
// Starts the specified action on a new thread and waits for it to exit
|
||
|
inline static void RunAwait(ThreadStart Action)
|
||
|
{
|
||
|
auto Runner = Thread(Action);
|
||
|
|
||
|
Runner.Start();
|
||
|
Runner.Join();
|
||
|
}
|
||
|
// Starts the specified action on a new thread with the given object and waits for it to exit
|
||
|
inline static void RunAwait(ParameterizedThreadStart Action, void* Object)
|
||
|
{
|
||
|
auto Runner = Thread(Action);
|
||
|
|
||
|
Runner.Start(Object);
|
||
|
Runner.Join();
|
||
|
}
|
||
|
};
|
||
|
}
|