[*] fix new build chain build issues

[-] test trash from workpairimpl
[+] Process.hpp impl stub
This commit is contained in:
Reece Wilson 2021-11-15 13:07:38 +00:00
parent d18affeea2
commit d4ec3749e7
9 changed files with 162 additions and 176 deletions

View File

@ -27,154 +27,7 @@ namespace Aurora::Async
void *opt;
};
#if 0
/// @hideinitializer
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>>
struct WorkPairImpl : IWorkItemHandler, std::enable_shared_from_this<IWorkItemHandler>
{
Info_t input;
Task_t task;
Job_t callback;
private:
static constexpr bool IsCallbackPtr = std::is_pointer_v<Job_t> || AuIsBaseOfTemplate<std::shared_ptr, Job_t>::value;
static constexpr bool IsTaskPtr = std::is_pointer_v<Task_t> || AuIsBaseOfTemplate<std::shared_ptr, Task_t>::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<std::remove_pointer_t<decltype(this)>>(this->shared_from_this());
AuFunction<void()> 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<void()> err = [pin]()
{
pin->CallOnFailure();
};
// TODO: this is somewhat evil. double alloc when we could reuse this
if (!caller_.pool->NewWorkItem(caller_, AuMakeShared<BasicWorkStdFunc>(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 (AuIsBaseOfTemplate<AuFunction, decltype(callback->onFailure)>::value)
{
if (!callback->onFailure)
{
return;
}
}
callback->onFailure(input);
}
else
{
if constexpr (AuIsBaseOfTemplate<AuFunction, decltype(callback.onFailure)>::value)
{
if (!callback.onFailure)
{
return;
}
}
callback.onFailure(input);
}
}
};
#else
template<typename Info_t = AVoid, typename Result_t = AVoid, typename Task_t = FTask<Info_t, Result_t>, typename Job_t = FJob<Info_t, Result_t>>
struct WorkPairImpl : IWorkItemHandler, std::enable_shared_from_this<IWorkItemHandler>
{
@ -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 (AuIsBaseOfTemplate<std::function, decltype(pin->callback->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
}

View File

@ -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<AuUInt8>(ELogLevel::eZero);
static auto const kLogLevelUsr = static_cast<AuUInt8>(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<typename ... T>
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<T>(args)...)));
WriteMessage(level, ConsoleMessage(EAnsiColor::eReset, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
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<T>(args)...)));
WriteMessage(level, ConsoleMessage(color, tag, fmt::format(msg, std::forward<T>(args)...)));
}
template<typename ... T>
inline void LogVerbose(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#if defined(STAGING) || defined(DEBUG)
template<typename ... T>
inline void LogVerboseNoShip(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eYellow, "Verbose", line, std::forward<T>(args)...);
}
#else
template<typename ... T>
inline void LogVerboseNoShip(const AuString &line, T&& ... args)
{
}
{}
#endif
inline void DoNothing()
{
@ -53,31 +68,31 @@ namespace Aurora::Console::Logging
template<typename ... T>
inline void LogInfo(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eGreen, "Info", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eInfo), EAnsiColor::eGreen, "Info", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogDbg(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eYellow, "Debug", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eDebug), EAnsiColor::eYellow, "Debug", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogWarn(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eRed, "Warn", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eWarn), EAnsiColor::eRed, "Warn", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogError(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eBoldRed, "Error", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eError), EAnsiColor::eBoldRed, "Error", line, std::forward<T>(args)...);
}
template<typename ... T>
inline void LogGame(const AuString &line, T&& ... args)
{
WriteLinef(EAnsiColor::eBlue, "Game", line, std::forward<T>(args)...);
WriteLinef(static_cast<AuUInt8>(ELogLevel::eVerbose), EAnsiColor::eBlue, "Game", line, std::forward<T>(args)...);
}
#endif
};

View File

@ -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,

View File

@ -26,14 +26,26 @@ namespace Aurora::Process
static AuList<EModulePath> kUserOverloadableSearchPath = {EModulePath::eSpecified, EModulePath::eModulePathCWD, EModulePath::eProcessDirectory, EModulePath::eModulePathUserDir, EModulePath::eModulePathSystemDir};
static AuList<EModulePath> kAdminOverloadableSearchPath = {EModulePath::eSpecified, EModulePath::eModulePathSystemDir, EModulePath::eProcessDirectory, EModulePath::eModulePathCWD, EModulePath::eModulePathUserDir};
static AuList<EModulePath> kSpecifiedPath = {EModulePath::eSpecified};
struct ModuleLoadRequest
{
inline ModuleLoadRequest(const AuList<AuString> &directories, const AuString &mod) : mod(mod), specifiedSearchPaths(&directories), searchPath(&kSpecifiedPath)
{}
inline ModuleLoadRequest(const AuList<AuString> &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<AuString> const *specifiedSearchPaths {};
AuList<EModulePath> const *searchPath {};
AuList<AuString> const * specifiedSearchPaths {};
AuList<EModulePath> const * searchPath {};
bool verify {}; // always effectively true if the executable is signed and enableMitigations is true
bool unixCheckPlusX {};
bool enableMitigations {true};

View File

@ -5,7 +5,7 @@
Date: 2021-11-1
Author: Reece
***/
#include <RuntimeInternal.hpp>
#include <Source/RuntimeInternal.hpp>
#include "Async.hpp"
#include "GroupState.hpp"

View File

@ -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
{

View File

@ -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)

View File

@ -6,7 +6,7 @@
Author: Reece
***/
#include <AuroraRuntime.hpp>
#include "RNG/WELL.hpp"
#include <Source/RNG/WELL.hpp>
#include "RandomDevice.hpp"
namespace Aurora::RNG

View File

@ -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<OSThread *>(that);
thiz->_ThreadEP();