diff --git a/Include/Aurora/Async/WorkPairImpl.hpp b/Include/Aurora/Async/WorkPairImpl.hpp index 1f9dd0d3..5dca55b7 100644 --- a/Include/Aurora/Async/WorkPairImpl.hpp +++ b/Include/Aurora/Async/WorkPairImpl.hpp @@ -27,154 +27,7 @@ namespace Aurora::Async void *opt; }; -#if 0 /// @hideinitializer - template, typename Job_t = FJob> - struct WorkPairImpl : IWorkItemHandler, std::enable_shared_from_this - { - - Info_t input; - Task_t task; - Job_t callback; - - - - private: - - static constexpr bool IsCallbackPtr = std::is_pointer_v || AuIsBaseOfTemplate::value; - static constexpr bool IsTaskPtr = std::is_pointer_v || AuIsBaseOfTemplate::value; - - WorkerPId_t caller_; - - BasicWorkCtx secretContext_; - Result_t resultValue_; - Threading::Primitives::SpinLock lock_; - - virtual void *GetPrivateData() override { return &secretContext_; } - - void DispatchFrame(ProcessInfo &info) override - { - - try - { - if constexpr (IsTaskPtr) - { - resultValue_ = task->onFrame(input); - } - else - { - resultValue_ = task.onFrame(input); - } - } - catch (...) - { - Debug::PrintError(); - Shutdown(); - return; - } - - auto pin = std::static_pointer_cast>(this->shared_from_this()); - - AuFunction func = [pin]() - { - try - { - pin->secretContext_.opt = &pin->resultValue_; - if constexpr (IsCallbackPtr) - { - pin->callback->onSuccess(pin->input, pin->resultValue_); - } - else - { - if (pin->callback.onSuccess) - { - pin->callback.onSuccess(pin->input,pin->resultValue_); - } - } - } - catch (...) - { - Debug::PrintError(); - } - }; - - try - { - - if (caller_ == Async::GetCurrentWorkerPId()) - { - func(); - } - else - { - AuFunction err = [pin]() - { - pin->CallOnFailure(); - }; - - // TODO: this is somewhat evil. double alloc when we could reuse this - if (!caller_.pool->NewWorkItem(caller_, AuMakeShared(func, err))->Dispatch()) - { - pin->CallOnFailure(); - } - } - - caller_ = {}; - } - catch (...) - { - Debug::PrintError(); - Shutdown(); - } - } - - void Shutdown() override - { - AU_LOCK_GUARD(this->lock_); - ShutdownNoLock(); - } - - inline void ShutdownNoLock() - { - caller_ = {}; - try - { - CallOnFailure(); - } - catch (...) - { - Debug::PrintError(); - } - } - - inline void CallOnFailure() - { - if constexpr (IsCallbackPtr) - { - if constexpr (AuIsBaseOfTemplateonFailure)>::value) - { - if (!callback->onFailure) - { - return; - } - } - - callback->onFailure(input); - } - else - { - if constexpr (AuIsBaseOfTemplate::value) - { - if (!callback.onFailure) - { - return; - } - } - callback.onFailure(input); - } - } - }; -#else template, typename Job_t = FJob> struct WorkPairImpl : IWorkItemHandler, std::enable_shared_from_this { @@ -247,7 +100,10 @@ namespace Aurora::Async { if constexpr (IsTaskPtr) { - resultValue_ = task->OnFrame(input); + if (task) + { + resultValue_ = task->OnFrame(input); + } } else { @@ -272,6 +128,15 @@ namespace Aurora::Async pin->secretContext_.opt = &pin->resultValue_; if constexpr (IsCallbackPtr) { + + if constexpr (AuIsBaseOfTemplatecallback->onSuccess)>::value) + { + if (!pin->callback->onSuccess) + { + return; + } + } + pin->callback->onSuccess(pin->input, pin->resultValue_); } else @@ -281,7 +146,7 @@ namespace Aurora::Async pin->callback.onSuccess(pin->input,pin->resultValue_); } } - } + } catch (...) { Debug::PrintError(); @@ -368,5 +233,4 @@ namespace Aurora::Async } } }; -#endif } \ No newline at end of file diff --git a/Include/Aurora/Console/Logging/ILogger.hpp b/Include/Aurora/Console/Logging/ILogger.hpp index 2357ff9e..5b056643 100644 --- a/Include/Aurora/Console/Logging/ILogger.hpp +++ b/Include/Aurora/Console/Logging/ILogger.hpp @@ -9,42 +9,57 @@ namespace Aurora::Console::Logging { + enum class ELogLevel + { + eZero = 0, + eInfo = 0, + eVerbose, + eError, + eDebug, + eWarn + }; + + static auto const kLogLevelDefault = static_cast(ELogLevel::eZero); + static auto const kLogLevelUsr = static_cast(ELogLevel::eWarn); + static auto const kLogLevelMax = 16; struct ILogger { - virtual void WriteMessage(const ConsoleMessage &msg) = 0; + virtual void WriteMessage(AuUInt8 level, const ConsoleMessage &msg) = 0; + + virtual void PushFilter(AuUInt8 level, bool shouldFilter) = 0; + virtual void PopFilter() = 0; #if defined(_AUHAS_FMT) template - inline void WriteLinef(const AuString &tag, const AuString &msg, T&& ... args) + inline void WriteLinef(AuUInt8 level, const AuString &tag, const AuString &msg, T&& ... args) { - WriteMessage(ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward(args)...))); + WriteMessage(level, ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward(args)...))); } template - inline void WriteLinef(EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args) + inline void WriteLinef(AuUInt8 level, EAnsiColor color, const AuString &tag, const AuString &msg, T&& ... args) { - WriteMessage(ConsoleMessage(color, tag, fmt::format(msg, std::forward(args)...))); + WriteMessage(level, ConsoleMessage(color, tag, fmt::format(msg, std::forward(args)...))); } - + template inline void LogVerbose(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); } - + #if defined(STAGING) || defined(DEBUG) template inline void LogVerboseNoShip(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward(args)...); } #else template inline void LogVerboseNoShip(const AuString &line, T&& ... args) - { - } + {} #endif - + inline void DoNothing() { @@ -53,31 +68,31 @@ namespace Aurora::Console::Logging template inline void LogInfo(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eGreen, "Info", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eInfo), EAnsiColor::eGreen, "Info", line, std::forward(args)...); } template inline void LogDbg(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eYellow, "Debug", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eDebug), EAnsiColor::eYellow, "Debug", line, std::forward(args)...); } template inline void LogWarn(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eRed, "Warn", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eWarn), EAnsiColor::eRed, "Warn", line, std::forward(args)...); } template inline void LogError(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eBoldRed, "Error", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eError), EAnsiColor::eBoldRed, "Error", line, std::forward(args)...); } template inline void LogGame(const AuString &line, T&& ... args) { - WriteLinef(EAnsiColor::eBlue, "Game", line, std::forward(args)...); + WriteLinef(static_cast(ELogLevel::eVerbose), EAnsiColor::eBlue, "Game", line, std::forward(args)...); } #endif }; diff --git a/Include/Aurora/Data/EDataType.hpp b/Include/Aurora/Data/EDataType.hpp index cfa1b04f..8cc783cc 100644 --- a/Include/Aurora/Data/EDataType.hpp +++ b/Include/Aurora/Data/EDataType.hpp @@ -11,7 +11,7 @@ namespace Aurora::Data { enum class EDataType { - kTypeUInt, // Human friendly types, used by parse, inherited by struct type members + kTypeUInt, // Text serialization -- Human friendly types, used by parse, inherited by struct type members kTypeSInt, kTypeNumber, kTypeString, @@ -20,7 +20,7 @@ namespace Aurora::Data kTypeVec3, kTypeVec4, - kTypeGenericMax, // Binary serialization, inherit pare types + kTypeGenericMax, // Binary serialization, inherit parse types kTypeStructFloat, kTypeStructUInt8, diff --git a/Include/Aurora/Process/Process.hpp b/Include/Aurora/Process/Process.hpp index 28157d22..f4c5449e 100644 --- a/Include/Aurora/Process/Process.hpp +++ b/Include/Aurora/Process/Process.hpp @@ -26,14 +26,26 @@ namespace Aurora::Process static AuList kUserOverloadableSearchPath = {EModulePath::eSpecified, EModulePath::eModulePathCWD, EModulePath::eProcessDirectory, EModulePath::eModulePathUserDir, EModulePath::eModulePathSystemDir}; static AuList kAdminOverloadableSearchPath = {EModulePath::eSpecified, EModulePath::eModulePathSystemDir, EModulePath::eProcessDirectory, EModulePath::eModulePathCWD, EModulePath::eModulePathUserDir}; + static AuList kSpecifiedPath = {EModulePath::eSpecified}; struct ModuleLoadRequest { + inline ModuleLoadRequest(const AuList &directories, const AuString &mod) : mod(mod), specifiedSearchPaths(&directories), searchPath(&kSpecifiedPath) + {} + + inline ModuleLoadRequest(const AuList &directories, const AuString &mod, const AuString &version) : mod(mod), version(version), specifiedSearchPaths(&directories), searchPath(&kSpecifiedPath) + {} + + inline ModuleLoadRequest(const AuString &mod) : mod(mod), searchPath(&kAdminOverloadableSearchPath) + {} + + inline ModuleLoadRequest(const AuString &mod, const AuString &version) : mod(mod), version(version), searchPath(&kAdminOverloadableSearchPath) + {} + AuString mod; AuString version; - AuString extension; - AuList const *specifiedSearchPaths {}; - AuList const *searchPath {}; + AuList const * specifiedSearchPaths {}; + AuList const * searchPath {}; bool verify {}; // always effectively true if the executable is signed and enableMitigations is true bool unixCheckPlusX {}; bool enableMitigations {true}; diff --git a/Source/Async/GroupState.cpp b/Source/Async/GroupState.cpp index 14422d3f..e95a738e 100644 --- a/Source/Async/GroupState.cpp +++ b/Source/Async/GroupState.cpp @@ -5,7 +5,7 @@ Date: 2021-11-1 Author: Reece ***/ -#include +#include #include "Async.hpp" #include "GroupState.hpp" diff --git a/Source/Async/ThreadPool.cpp b/Source/Async/ThreadPool.cpp index 9b371307..4afc0aac 100644 --- a/Source/Async/ThreadPool.cpp +++ b/Source/Async/ThreadPool.cpp @@ -454,7 +454,7 @@ namespace Aurora::Async if (block) { // TODO (reece): work on async epoll like abstraction - nextLoopSources = Loop::WaitMultipleObjects(curLoopSources, 0); + nextLoopSources = Loop::WaitMultipleOrObjects(curLoopSources, 0); } else { diff --git a/Source/Process/Process.cpp b/Source/Process/Process.cpp index 95469b03..485abe0e 100644 --- a/Source/Process/Process.cpp +++ b/Source/Process/Process.cpp @@ -13,6 +13,101 @@ namespace Aurora::Process { + static constexpr const char *GetPlatformString(Build::EPlatform platform) + { + switch (platform) + { + case Build::EPlatform::ePlatformWin32: + return ".Win32"; + case Build::EPlatform::ePlatformLinux: + return ".Linux"; + case Build::EPlatform::ePlatformAndroid: + return ".Android"; + case Build::EPlatform::ePlatformApple: + return ".Mac"; + case Build::EPlatform::ePlatformIos: + return ".IOS"; + default: + return nullptr; + } + } + + static constexpr const char *GetPlatformExt(Build::EPlatform platform) + { + switch (platform) + { + case Build::EPlatform::ePlatformWin32: + return ".dll"; + case Build::EPlatform::ePlatformLinux: + case Build::EPlatform::ePlatformAndroid: + return ".so"; + case Build::EPlatform::ePlatformApple: + case Build::EPlatform::ePlatformIos: + return ".dynlib"; + default: + return nullptr; + } + } + + static constexpr const char *GetArchString(Build::EArchitecture architecture) + { + switch (architecture) + { + case Build::EArchitecture::eX86_32: + return ".x86_32"; + case Build::EArchitecture::eX86_64: + return ".x86_64"; + case Build::EArchitecture::eAArch64: + return ".Arm"; + default: + return nullptr; + } + } + + static constexpr AuString ConstructAuDllSuffix() + { + auto platform = GetPlatformString(Build::kCurrentPlatform); + auto architecture = GetArchString(Build::kCurrentArchitecture); + auto ext = GetPlatformExt(Build::kCurrentPlatform); + + AuString ret; + + #if defined(DEBUG) + ret += ".Debug"; + #elif defined(STAGING) + ret += ".Stage"; + #elif defined(SHIP) + ret += ".Ship"; + #endif + + if (platform) + { + ret += platform; + } + + if (architecture) + { + ret += architecture; + } + + if (ext) + { + ret += ext; + } + + return ret; + } + + AUKN_SYM bool LoadModule(const ModuleLoadRequest &request) + { + return false; + } + + AUKN_SYM AuMach GetProcAddress(AuString mod, AuString symbol) + { + return {}; + } + AUKN_SYM void Exit(AuUInt32 exitcode) { #if defined(AURORA_IS_MODERNNT_DERIVED) diff --git a/Source/RNG/RandomDevice.cpp b/Source/RNG/RandomDevice.cpp index bd44c76c..0a4f50b4 100644 --- a/Source/RNG/RandomDevice.cpp +++ b/Source/RNG/RandomDevice.cpp @@ -6,7 +6,7 @@ Author: Reece ***/ #include -#include "RNG/WELL.hpp" +#include #include "RandomDevice.hpp" namespace Aurora::RNG diff --git a/Source/Threading/Threads/OSThread.cpp b/Source/Threading/Threads/OSThread.cpp index 387ba8f7..423cdcf3 100644 --- a/Source/Threading/Threads/OSThread.cpp +++ b/Source/Threading/Threads/OSThread.cpp @@ -315,7 +315,7 @@ namespace Aurora::Threading::Threads // I think I switched it from CreateThread to _beginthreadex at somepoint and i don't remember why #if defined(AURORA_IS_MODERNNT_DERIVED) - unsigned(*OSEP_f)(void *) = [](void *that) -> unsigned + unsigned(WINAPI *OSEP_f)(void *) = [](void *that) -> unsigned { auto thiz = reinterpret_cast(that); thiz->_ThreadEP();