AuroraRuntime/Include/Aurora/RuntimeAliases.hpp
Jamie Reece Wilson 62917318af [+] (reference futex primitive) AuFutexMutexSpecial = AuThreading::Waitables::FutexWaitableNoVTblMovable
[+] (reference futex primitive) AuFutexMutexSmallest = AuThreading::Waitables::FutexWaitableNoVTblMovableSmallest

...because i cant be arsed
2024-04-16 04:30:31 +01:00

239 lines
8.1 KiB
C++

/***
Copyright (C) 2023 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: RuntimeAliases.hpp
Date: 2023-12-1
Author: Reece
***/
#pragma once
namespace AuAsync = Aurora::Async;
namespace AuBuild = Aurora::Build;
namespace AuCompression = Aurora::Compression;
namespace AuConsole = Aurora::Console;
namespace AuCmdLine = Aurora::CmdLine;
namespace AuCrypto = Aurora::Crypto;
namespace AuData = Aurora::Data;
namespace AuDebug = Aurora::Debug;
namespace AuThreading = Aurora::Threading;
namespace AuThreadPrimitives = Aurora::Threading::Primitives;
namespace AuThreads = Aurora::Threading::Threads;
namespace AuHwInfo = Aurora::HWInfo;
namespace AuSwInfo = Aurora::SWInfo;
namespace AuHWInfo = Aurora::HWInfo;
namespace AuSWInfo = Aurora::SWInfo;
namespace AuIO = Aurora::IO;
namespace AuIOFS = Aurora::IO::FS;
namespace AuIONet = Aurora::IO::Net;
namespace AuIOIPC = Aurora::IO::IPC;
namespace AuIOLoop = Aurora::IO::Loop;
namespace AuIOProtocol = Aurora::IO::Protocol;
// Legacy shorthands; wont deprecate
namespace AuIPC = Aurora::IO::IPC;
namespace AuLoop = Aurora::IO::Loop;
namespace AuNet = Aurora::IO::Net;
namespace AuFS = Aurora::IO::FS;
namespace AuProtocol = Aurora::IO::Protocol;
namespace AuRng = Aurora::RNG;
namespace AuRNG = Aurora::RNG;
namespace AuLocale = Aurora::Locale;
namespace AuParse = Aurora::Parse;
namespace AuProcess = Aurora::Process;
namespace AuProcesses = Aurora::Processes;
namespace AuTelemetry = Aurora::Telemetry;
namespace AuTime = Aurora::Time;
namespace AuTypes = Aurora::Types;
namespace AuLog = Aurora::Logging;
namespace AuMemory = Aurora::Memory;
namespace AuHashing = Aurora::Hashing;
namespace AuExit = Aurora::Exit;
namespace AuUtility = Aurora::Utility;
using AuWorkerId_t = AuAsync::WorkerId_t;
using AuWorkerPId_t = AuAsync::WorkerPId_t;
using AuWorkerId = AuAsync::WorkerId_t;
using AuWorkerPId = AuAsync::WorkerPId_t;
using AuWorkerID = AuAsync::WorkerPId_t;
using AuByteBuffer = AuMemory::ByteBuffer;
using AuMemoryViewRead = AuMemory::MemoryViewRead;
using AuMemoryViewWrite = AuMemory::MemoryViewWrite;
using AuMemoryViewStreamRead = AuMemory::MemoryViewStreamRead;
using AuMemoryViewStreamWrite = AuMemory::MemoryViewStreamWrite;
#if defined(AURORA_RUNTIME_BAD_PLATFORM_FORCE_FUTEX_MUTEX_SEMAPHORE_IN_CLIENT)
using AuMutex = AuThreading::Waitables::FutexWaitable;
using AuSemaphore = AuThreading::Waitables::FutexSemaphoreWaitable;
#else
using AuMutex = AuThreadPrimitives::Mutex;
using AuSemaphore = AuThreadPrimitives::Semaphore;
#endif
using AuRenterableMutex = AuThreadPrimitives::CriticalSection;
using AuCriticalSection = AuThreadPrimitives::CriticalSection;
using AuRWRenterableLock = AuThreadPrimitives::RWRenterableLock;
using AuRWLock = AuThreadPrimitives::RWLock;
using AuCond = AuThreadPrimitives::ConditionVariable;
using AuConditionVariable = AuThreadPrimitives::ConditionVariable;
using AuConditionMutex = AuThreadPrimitives::ConditionMutex;
using AuCondition = AuThreadPrimitives::ConditionVariable;
using AuCondMutex = AuThreadPrimitives::ConditionMutex;
using AuSpinLock = AuThreadPrimitives::SpinLock;
using AuCondEx = AuThreadPrimitives::FlexibleConditionVariable;
using AuFlexibleConditionVariable = AuThreadPrimitives::FlexibleConditionVariable;
using AuConditionEx = AuThreadPrimitives::FlexibleConditionVariable;
using AuBinarySemaphore = AuThreadPrimitives::Event;
using AuEvent = AuThreadPrimitives::Event;
using AuFutexMutex = AuThreading::Waitables::FutexWaitable;
using AuFutexMutexSpecial = AuThreading::Waitables::FutexWaitableNoVTblMovable;
// Note: a reference U16/U8 reference impl would be pointless - threefold
// 1) x86_64 chokes on 16bit atomics;
// 2) 32bit RISC ISAs would prefer 32bit words;
// 3) sub 32bit words are just going to junk up our alignment & introduce pointless padding
using AuFutexMutexSmallest = AuThreading::Waitables::FutexWaitableNoVTblMovableSmallest;
// TODO:
//using AuFutexTicketMutex = AuThreading::Waitables::FutexTicketWaitable;
using AuFutexSemaphore = AuThreading::Waitables::FutexSemaphoreWaitable;
using AuFutexCond = AuThreading::Waitables::FutexCondWaitable;
using AuFutexCondition = AuThreading::Waitables::FutexCondWaitable;
using AuFutexBarrier = AuThreading::Waitables::FutexBarrier;
using AuBarrier = AuThreading::Waitables::FutexBarrier;
using AuInitOnce = AuThreading::InitOnce;
using AuInitOnceSmall = __audetail::InitOnceABI;
template<typename T, bool bIsStatic = false>
using AuTLSVariable = AuThreads::TLSVariable<T, bIsStatic>;
using AuIOHandle = AuIO::IOHandle;
using AuSharedIOHandle = AuSPtr<AuIO::IOHandle>;
static bool AuIsThreadRunning()
{
return !AuThreads::GetThread()->Exiting();
}
static inline void AuDebugBreak()
{
AuDebug::DebugBreak();
}
template <typename T>
using AuHUPOf_t = typename Aurora::Memory::Heap::HUPOf_t<T>;
template <class T>
auto AuNullHeapPointer()
{
return Aurora::Memory::Heap::NullUniquePointer<T>();
}
template <class T>
auto AuNullPointer()
{
return Aurora::Memory::Heap::NullUniquePointer<T>();
}
template <class T, class ...Args>
AuHUPOf_t<T> AuNewClassArrayUnique(AuUInt uElements, Args &&... fillCtr)
{
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClassArrayUnique<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
}
template <class T, class ...Args>
AuSPtr<T> AuNewClassArray(AuUInt uElements, Args &&... fillCtr)
{
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClassArray<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
}
template <class T, class Z = T, class ...Args>
AuHUPOf_t<Z> AuNewClassUnique(Args &&...args)
{
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClassUnique<T, Z, Args...>(AuForward<Args>(args)...);
}
template <class T, class ...Args>
AuSPtr<T> AuNewClass(Args &&...args)
{
return Aurora::Memory::GetDefaultDiscontiguousHeap()->NewClass<T, Args...>(AuForward<Args>(args)...);
}
template <class T, class ...Args>
AuHUPOf_t<T> AuNewClassArrayUnique(Aurora::Memory::Heap *pHeap, AuUInt uElements, Args &&... fillCtr)
{
return pHeap->NewClassArrayUnique<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
}
template <class T, class ...Args>
AuSPtr<T> AuNewClassArray(Aurora::Memory::Heap *pHeap, AuUInt uElements, Args &&... fillCtr)
{
return pHeap->NewClassArray<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
}
template <class T, class ...Args>
AuHUPOf_t<T> AuNewClassUnique(Aurora::Memory::Heap *pHeap, Args &&...args)
{
return pHeap->NewClassUnique<T, Args...>(AuForward<Args>(args)...);
}
template <class T, class ...Args>
AuSPtr<T> AuNewClass(Aurora::Memory::Heap *pHeap, Args &&...args)
{
return pHeap->NewClass<T, Args...>(AuForward<Args>(args)...);
}
template <class T, class ...Args>
AuHUPOf_t<T> AuNewClassArrayUnique(const AuSPtr<Aurora::Memory::Heap> &pHeap, AuUInt uElements, Args &&... fillCtr)
{
return pHeap->NewClassArrayUnique<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
}
template <class T, class ...Args>
AuSPtr<T> AuNewClassArray(const AuSPtr<Aurora::Memory::Heap> &pHeap, AuUInt uElements, Args &&... fillCtr)
{
return pHeap->NewClassArray<T, Args...>(uElements, AuForward<Args>(fillCtr)...);
}
template <class T, class Z = T, class ...Args>
AuHUPOf_t<Z> AuNewClassUnique(const AuSPtr<Aurora::Memory::Heap> &pHeap, Args &&...args)
{
return pHeap->NewClassUnique<T, Z, Args...>(AuForward<Args>(args)...);
}
template <class T, class ...Args>
AuSPtr<T> AuNewClass(const AuSPtr<Aurora::Memory::Heap> &pHeap, Args &&...args)
{
return pHeap->NewClass<T, Args...>(AuForward<Args>(args)...);
}
template <class Z, class T>
AuHUPOf_t<Z> AuCastPointer(AuHUPOf_t<T> &&pInPointer)
{
return Aurora::Memory::Heap::CastPointer<Z>(AuMove(pInPointer));
}
static AuSPtr<AuMemory::SharableByteBuffer> AuNewSharableBuffer(AuUInt32 length = 0)
{
return AuMove(AuMemory::NewSharableBuffer(length));
}
static AuSPtr<AuMemory::SharableByteBuffer> AuNewSharableResizableBuffer(AuUInt32 length = 0)
{
return AuMove(AuMemory::NewSharableResizableBuffer(length));
}
static AuByteBuffer AuNewRingBuffer(AuUInt32 length = 1024 * 5)
{
return AuMove(AuMemory::NewRingBuffer(length));
}
static AuByteBuffer AuNewResizableBuffer(AuUInt32 length = 0)
{
return AuMove(AuMemory::NewResizableBuffer(length));
}