[*] Major fix -> vec wrapper w/o glm accessors were broken
[*] Preemptive linux/clang API fixes [*] Fix clang equiv MSVC template bug (they're nice enough to throw an error instead of crashing)
This commit is contained in:
parent
e0d83e33a3
commit
b29f8ebf21
@ -17,17 +17,16 @@
|
||||
#include "Jobs.hpp"
|
||||
#include "Tasks.hpp"
|
||||
|
||||
|
||||
namespace Aurora::Async
|
||||
{
|
||||
AUKN_SYM IAsyncApp *GetAsyncApp();
|
||||
AUKN_SYM IAsyncApp *GetAsyncApp();
|
||||
|
||||
///
|
||||
AUKN_SYM WorkerPId_t GetCurrentWorkerPId();
|
||||
|
||||
|
||||
/// Async app only | Thread pools must use the IThreadPool::NewFence function
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerId_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking = false);
|
||||
|
||||
|
||||
AUKN_SYM AuSPtr<IWorkItem> NewWorkItem(const WorkerPId_t &worker, const AuSPtr<IWorkItemHandler> &task, bool supportsBlocking = false);
|
||||
|
||||
/// Async app only | Thread pools must use the IThreadPool::NewFence function
|
||||
@ -35,160 +34,12 @@ namespace Aurora::Async
|
||||
|
||||
/// Allocates a new thread pool for usage
|
||||
AUKN_SYM AuSPtr<IThreadPool> NewThreadPool();
|
||||
|
||||
// TODO: move the following trash out of here
|
||||
// the following is mostly old trash
|
||||
#pragma region EASE_OF_READING
|
||||
struct BasicWorkStdFunc : IWorkItemHandler
|
||||
{
|
||||
AuFunction<void()> callback;
|
||||
AuFunction<void()> shutdown; // error
|
||||
|
||||
BasicWorkStdFunc(AuFunction<void()> &&callback, AuFunction<void()> &&shutdown) : callback(AuMove(callback)), shutdown(AuMove(shutdown))
|
||||
{}
|
||||
|
||||
BasicWorkStdFunc(AuFunction<void()> &&callback) : callback(AuMove(callback))
|
||||
{}
|
||||
|
||||
BasicWorkStdFunc(const AuFunction<void()> &callback) : callback(callback)
|
||||
{}
|
||||
|
||||
BasicWorkStdFunc(const AuFunction<void()> &callback, const AuFunction<void()> &shutdown) : callback(callback), shutdown(shutdown)
|
||||
{}
|
||||
|
||||
private:
|
||||
#if !defined(_CPPSHARP)
|
||||
void DispatchFrame(ProcessInfo &info) override
|
||||
{
|
||||
try
|
||||
{
|
||||
callback();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Debug::PrintError();
|
||||
}
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
try
|
||||
{
|
||||
if (shutdown)
|
||||
{
|
||||
shutdown();
|
||||
}
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
Debug::PrintError();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#if !defined(_CPPSHARP)
|
||||
|
||||
/// @hideinitializer
|
||||
template<typename Frame_t = AuFunction<void()>, typename Cleanup_t = AuFunction<void()>>
|
||||
struct WorkItemCallable : IWorkItemHandler
|
||||
{
|
||||
Frame_t frame;
|
||||
Cleanup_t cleanup;
|
||||
|
||||
private:
|
||||
void DispatchFrame(ProcessInfo &info) override
|
||||
{
|
||||
if constexpr (AuIsBaseOfTemplate<Frame_t, decltype(frame)>::value)
|
||||
{
|
||||
if (!frame)
|
||||
{
|
||||
info.type = IWorkItemHandler::EProcessNext::eFinished;
|
||||
return;
|
||||
}
|
||||
}
|
||||
frame();
|
||||
info.type = IWorkItemHandler::EProcessNext::eFinished;
|
||||
}
|
||||
|
||||
void Shutdown() override
|
||||
{
|
||||
if constexpr (AuIsBaseOfTemplate<Cleanup_t, decltype(cleanup)>::value)
|
||||
{
|
||||
if (!cleanup)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
cleanup();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
#define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v<T, bool>) { SysPushErrorGen(exp); return {}; } else { throw AuString(exp); } }
|
||||
#define ASYNC_FINISH { if constexpr (AuIsSame_v<T, bool>) { return true; } }
|
||||
|
||||
template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
|
||||
static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<void(Args...)> func)
|
||||
{
|
||||
if (!func) return {};
|
||||
return [=](Args&&... in) -> T
|
||||
{
|
||||
auto work = AuMakeShared<BasicWorkStdFunc>([=]() -> void {
|
||||
func(in...);
|
||||
});
|
||||
if (!work) ASYNC_ERROR("can't dispatch async call. out of memory");
|
||||
auto workItem = NewWorkItem(id, work);
|
||||
if (!workItem) ASYNC_ERROR("can't dispatch async call. out of memory");
|
||||
workItem->Dispatch();
|
||||
ASYNC_FINISH;
|
||||
};
|
||||
}
|
||||
|
||||
/// Async app only
|
||||
template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
|
||||
static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcher(AuFunction<void(Args...)> func)
|
||||
{
|
||||
return TranslateAsyncFunctionToDispatcherWithThread(GetAsyncApp()->GetCurrentThread(), func);
|
||||
}
|
||||
|
||||
/// Async app only
|
||||
template<typename B = void, typename T, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
|
||||
static AuFunction<T(AuFunction<void(const B&)>, Args...)> TranslateAsyncReturnableFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<B(Args...)> func)
|
||||
{
|
||||
return [=](AuFunction<T(const B&)> callback, Args... in) -> T
|
||||
{
|
||||
auto work = AuMakeShared<WorkPairImpl<AVoid, B>>();
|
||||
if (!work) ASYNC_ERROR("can't dispatch async call; out of memory");
|
||||
work.task.onProcess = [=](const AVoid &) -> B
|
||||
{
|
||||
if (!func) return B{};
|
||||
return func(in...);
|
||||
};
|
||||
work.callback.onSuccess = [=](const AVoid &, const B &ret)
|
||||
{
|
||||
callback(ret);
|
||||
};
|
||||
auto workItem = NewWorkItem(id, work);
|
||||
if (!workItem) ASYNC_ERROR("can't dispatch async call; out of memory");
|
||||
workItem->Dispatch();
|
||||
ASYNC_FINISH;
|
||||
};
|
||||
}
|
||||
|
||||
#undef ASYNC_ERROR
|
||||
#undef ASYNC_FINISH
|
||||
|
||||
#endif
|
||||
|
||||
#pragma endregion EASE_OF_READING
|
||||
}
|
||||
|
||||
|
||||
#if !defined(_CPPSHARP)
|
||||
#include "JobFrom.hpp"
|
||||
#include "TaskFrom.hpp"
|
||||
#include "WorkPairImpl.hpp"
|
||||
#include "WorkBasic.hpp"
|
||||
#endif
|
||||
#include "JobFrom.hpp"
|
||||
#include "TaskFrom.hpp"
|
||||
#include "WorkPairImpl.hpp"
|
||||
#include "WorkBasic.hpp"
|
||||
#include "OldTrash.hpp"
|
||||
#endif
|
||||
|
60
Include/Aurora/Async/OldTrash.hpp
Executable file
60
Include/Aurora/Async/OldTrash.hpp
Executable file
@ -0,0 +1,60 @@
|
||||
#pragma once
|
||||
|
||||
namespace Aurora::Async
|
||||
{
|
||||
#define ASYNC_ERROR(exp) { if constexpr (AuIsSame_v<T, bool>) { SysPushErrorGen(exp); return {}; } else { throw AuString(exp); } }
|
||||
#define ASYNC_FINISH { if constexpr (AuIsSame_v<T, bool>) { return true; } }
|
||||
|
||||
template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
|
||||
static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<void(Args...)> func)
|
||||
{
|
||||
if (!func) return {};
|
||||
return [=](Args&&... in) -> T
|
||||
{
|
||||
auto work = AuMakeShared<BasicWorkStdFunc>([=]() -> void {
|
||||
func(in...);
|
||||
});
|
||||
if (!work) ASYNC_ERROR("can't dispatch async call. out of memory");
|
||||
auto workItem = NewWorkItem(id, work);
|
||||
if (!workItem) ASYNC_ERROR("can't dispatch async call. out of memory");
|
||||
workItem->Dispatch();
|
||||
ASYNC_FINISH;
|
||||
};
|
||||
}
|
||||
|
||||
/// Async app only
|
||||
template<typename T = void, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
|
||||
static AuFunction<T(Args&&...)> TranslateAsyncFunctionToDispatcher(AuFunction<void(Args...)> func)
|
||||
{
|
||||
return TranslateAsyncFunctionToDispatcherWithThread(GetAsyncApp()->GetCurrentThread(), func);
|
||||
}
|
||||
|
||||
/// Async app only
|
||||
template<typename B = void, typename T, typename... Args, AU_TEMPLATE_ENABLE_WHEN(AuIsSame_v<T, bool> || AuIsVoid_v<T>)>
|
||||
static AuFunction<T(AuFunction<void(const B&)>, Args...)> TranslateAsyncReturnableFunctionToDispatcherWithThread(WorkerId_t id, AuFunction<B(Args...)> func)
|
||||
{
|
||||
return [=](AuFunction<T(const B&)> callback, Args... in) -> T
|
||||
{
|
||||
auto work = AuMakeShared<WorkPairImpl<AVoid, B>>();
|
||||
if (!work) ASYNC_ERROR("can't dispatch async call; out of memory");
|
||||
work.task.onProcess = [=](const AVoid &) -> B
|
||||
{
|
||||
if (!func) return B{};
|
||||
return func(in...);
|
||||
};
|
||||
work.callback.onSuccess = [=](const AVoid &, const B &ret)
|
||||
{
|
||||
callback(ret);
|
||||
};
|
||||
auto workItem = NewWorkItem(id, work);
|
||||
if (!workItem) ASYNC_ERROR("can't dispatch async call; out of memory");
|
||||
workItem->Dispatch();
|
||||
ASYNC_FINISH;
|
||||
};
|
||||
}
|
||||
|
||||
#undef ASYNC_ERROR
|
||||
#undef ASYNC_FINISH
|
||||
|
||||
#pragma endregion EASE_OF_READING
|
||||
}
|
@ -43,7 +43,7 @@ namespace Aurora::Async
|
||||
FTask<AuTuple<Args...>, Out_t> TaskFromTupleCallableWithOwnerArg(AuFunction<Out_t(Args...)> &&func, const Owner_t &ownerToPin)
|
||||
{
|
||||
FTask<AuTuple<Owner_t, Args...>, Out_t> ret;
|
||||
ret.onFrame = [callable = func](const AuTuple<Args...> &in) -> Out_t
|
||||
ret.onFrame = [ownerToPin, callable = func](const AuTuple<Args...> &in) -> Out_t
|
||||
{
|
||||
return AuTupleApply(callable, AuTupleCat(AuMakeTuple<Owner_t>(ownerToPin), in));
|
||||
};
|
||||
@ -83,4 +83,4 @@ namespace Aurora::Async
|
||||
};
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -76,7 +76,7 @@ namespace Aurora::IO::Net
|
||||
|
||||
struct SocketHostName
|
||||
{
|
||||
SocketHostName(const AuString &name) : info(ESocketInfo::eByDns), hostname(name), address({})
|
||||
SocketHostName(const AuString &name) : info(ESocketInfo::eByDns), hostname(name), address()
|
||||
{}
|
||||
|
||||
SocketHostName(const IPAddress &endpoint) : info(ESocketInfo::eByEndpoint), address(endpoint), hostname()
|
||||
|
@ -7,6 +7,7 @@
|
||||
***/
|
||||
#pragma once
|
||||
|
||||
//#include <auROXTL/auCastUtils.hpp>
|
||||
#include <auROXTL/auCopyMoveUtils.hpp>
|
||||
|
||||
namespace Aurora::Memory
|
||||
@ -35,8 +36,8 @@ namespace Aurora::Memory
|
||||
, private _detail::IPtrGet
|
||||
#endif
|
||||
{
|
||||
using element_type = Base_t::element_type;
|
||||
using weak_type = Base_t::weak_type;
|
||||
using element_type = typename Base_t::element_type;
|
||||
using weak_type = typename Base_t::weak_type;
|
||||
using base_type = Base_t;
|
||||
using Base_t::Base_t;
|
||||
|
||||
@ -265,7 +266,7 @@ namespace Aurora::Memory
|
||||
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
|
||||
return Base_t::operator->();
|
||||
#elif !defined(_AURORA_NULLEXPT_BRANCH)
|
||||
return AuReinterpretCast<TType2_t>(ptr->Get());
|
||||
return reinterpret_cast<TType2_t *>(ptr->Get());
|
||||
#else
|
||||
throwif();
|
||||
return Base_t::operator->();
|
||||
@ -284,7 +285,7 @@ namespace Aurora::Memory
|
||||
#if defined(_AURORA_NULLEXPT_ENABLE_UB)
|
||||
return Base_t::operator->();
|
||||
#elif !defined(_AURORA_NULLEXPT_BRANCH)
|
||||
return AuReinterpretCast<TType2_t>(ptr->Get());
|
||||
return reinterpret_cast<TType2_t *>(ptr->Get());
|
||||
#else
|
||||
throwif();
|
||||
return Base_t::operator->();
|
||||
@ -389,4 +390,4 @@ namespace Aurora::Memory
|
||||
return Base_t::shared_from_this();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -40,7 +40,7 @@ namespace Aurora::RNG
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T &NextFillRange(const T &items)
|
||||
inline T &NextFillRange(const T &items)
|
||||
{
|
||||
NextFillArray(items.begin(), items.end() - items.begin());
|
||||
}
|
||||
@ -72,7 +72,7 @@ namespace Aurora::RNG
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
static inline T &NextRange(const T &items)
|
||||
inline T &NextRange(const T &items)
|
||||
{
|
||||
return NextIterator(items.begin(), items.end());
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace Aurora::Threading::Threads
|
||||
ThreadInfo(const AuSPtr<IThreadVectors> &callbacks, const AuString &name, AuUInt32 stackSize) : callbacks(callbacks), name(name), stackSize(stackSize)
|
||||
{}
|
||||
|
||||
ThreadInfo(const AuSPtr<IThreadVectors> &callbacks, AuUInt32 stackSize) : callbacks(callbacks), name(name), stackSize(stackSize)
|
||||
ThreadInfo(const AuSPtr<IThreadVectors> &callbacks, AuUInt32 stackSize) : callbacks(callbacks), stackSize(stackSize)
|
||||
{}
|
||||
|
||||
AuSPtr<IThreadVectors> callbacks;
|
||||
|
@ -226,7 +226,7 @@ inline auline T AuAtomicUtils<T>::Set(T *in, AuUInt8 offset)
|
||||
template<typename T>
|
||||
inline auline bool AuAtomicUtils<T>::TestAndSet(T *in, const AuUInt8 offset)
|
||||
{
|
||||
return AuAtomicSet<T>::Set(in, offset) & (1 << offset);
|
||||
return AuAtomicUtils<T>::Set(in, offset) & (1 << offset);
|
||||
}
|
||||
|
||||
#if defined(AURORA_COMPILER_MSVC) && (defined(AURORA_ARCH_X64) || defined(AURORA_ARCH_X86))
|
||||
@ -304,4 +304,4 @@ auline
|
||||
bool AuAtomicTestAndSet(T *in, AuUInt8 offset)
|
||||
{
|
||||
return AuAtomicUtils<T>::TestAndSet(in, offset);
|
||||
}
|
||||
}
|
||||
|
@ -155,11 +155,11 @@ static AuUInt8 AuPopCnt(T in)
|
||||
#endif
|
||||
#else
|
||||
if constexpr (sizeof(T) == sizeof(unsigned long long))
|
||||
return __builtin_popcountll(static_cast<unsigned long long>(value));
|
||||
return __builtin_popcountll(static_cast<unsigned long long>(in));
|
||||
else if constexpr (sizeof(T) == sizeof(unsigned long))
|
||||
return __builtin_popcountl(static_cast<unsigned long>(value));
|
||||
return __builtin_popcountl(static_cast<unsigned long>(in));
|
||||
else if constexpr (sizeof(T) == sizeof(unsigned int))
|
||||
return __builtin_popcount(static_cast<unsigned int>(value));
|
||||
return __builtin_popcount(static_cast<unsigned int>(in));
|
||||
#endif
|
||||
|
||||
#if defined(AU_CPU_ENDIAN_LITTLE)
|
||||
|
@ -70,7 +70,7 @@ static auline AuSPtr<T> AuMakeSharedArray(AuUInt count)
|
||||
{
|
||||
try
|
||||
{
|
||||
#if defined(AU_LANG_CPP_20) && !defined(AURORA_COMPILER_MSVC)
|
||||
#if defined(AU_LANG_CPP_20) && 0
|
||||
return AURORA_RUNTIME_AU_SHARED_PTR<T[]>(count);
|
||||
#else
|
||||
return AURORA_RUNTIME_AU_SHARED_PTR<T>(new T[count], AuDefaultDeleter<T[]>());
|
||||
|
@ -82,18 +82,37 @@ template<>
|
||||
struct AuNumericLimits<char32_t> : AuNumericLimits<AuUInt32>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct AuNumericLimits<float> : _AuNonStdLimits<float,
|
||||
float(-340282346638528859811704183484516925440.0000000000000000),
|
||||
float(340282346638528859811704183484516925440.0000000000000000),
|
||||
float(0.0000000596)>
|
||||
{};
|
||||
template<typename T>
|
||||
struct _AuNonStdLimitsFP
|
||||
{
|
||||
using Type = T;
|
||||
|
||||
static const bool is_signed = true;
|
||||
static const bool is_integer = false;
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AuNumericLimits<double> : _AuNonStdLimits<double,
|
||||
double(0), // specifying these arguments, even below the limit, will crash msvcs frontend
|
||||
double(1),
|
||||
double(0.000000000000000111)>
|
||||
struct AuNumericLimits<float> : _AuNonStdLimitsFP<float>
|
||||
{
|
||||
static double max()
|
||||
{
|
||||
return 340282346638528859811704183484516925440.0000000000000000;
|
||||
}
|
||||
|
||||
static double min()
|
||||
{
|
||||
return -340282346638528859811704183484516925440.0000000000000000;
|
||||
}
|
||||
|
||||
static constexpr double epsilon()
|
||||
{
|
||||
return 0.000000000000000111;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<>
|
||||
struct AuNumericLimits<double> : _AuNonStdLimitsFP<double>
|
||||
{
|
||||
static double max()
|
||||
{
|
||||
@ -104,4 +123,9 @@ struct AuNumericLimits<double> : _AuNonStdLimits<double,
|
||||
{
|
||||
return -2.2250738585072014e-308;
|
||||
}
|
||||
|
||||
static constexpr double epsilon()
|
||||
{
|
||||
return 0.000000000000000111;
|
||||
}
|
||||
};
|
@ -28,12 +28,12 @@
|
||||
|
||||
inline float operator [](int idx) const
|
||||
{
|
||||
return elements[N];
|
||||
return elements[idx];
|
||||
}
|
||||
|
||||
inline float &operator [](int idx)
|
||||
{
|
||||
return elements[N];
|
||||
return elements[idx];
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
#pragma once
|
||||
|
||||
#if defined(__has_include)
|
||||
#if __has_include(<intrin.h>)
|
||||
#if __has_include(<intrin.h>) && defined(AURORA_PLATFORM_WIN32)
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
#if __has_include(<emmintrin.h>)
|
||||
@ -79,4 +79,4 @@ struct AuNullCallback
|
||||
callbackFunc->OnCall();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user