AuroraRuntime/Include/Aurora/Runtime.hpp
Reece 99c5e1fa65 A pretty large patch not worth breaking up into separate commits
[*] Split up Aurora Async
[*] Split Async app into seperate ThreadPool concept
[*] Fix various OSThread bugs and tls transfer issues
[*] Set default affinity to 0xFFFFFFFF
[*] Update Build script
[+] Add AuTuplePopFront
[+] New Network Interface (unimplemented)
[*] Stub out the interfaces required for a better logger
[*] Fix Win32 ShellExecute bug; windows 11 struggles without explicit com init per the docs - now deferring to thread pool
[*] Update gitignore
[*] Follow XDG home standard
[*] Refactor some namespaces to use the shorthand aliases
[*] Various stability fixes
2021-11-05 17:34:23 +00:00

256 lines
7.3 KiB
C++

/***
Copyright (C) 2021 J Reece Wilson (a/k/a "Reece"). All rights reserved.
File: Runtime.hpp
Date: 2021-6-9
Author: Reece
***/
#pragma once
#if defined(AURORA_ENGINE_KERNEL_STATIC)
#define AUKN_SYM
#else
#if defined(AURORA_ENGINE_KERNEL_EXPORT)
#define AUKN_SYM AURORA_SYMBOL_EXPORT
#else
#define AUKN_SYM AURORA_SYMBOL_IMPORT
#endif
#endif
#include <AuroraForEach.hpp>
#include <AuroraInterfaces.hpp>
#include <AuroraEnum.hpp>
#include "../AuroraMacros.hpp"
#include <utilitY>
#include <memory>
#include <optional>
#include <functional>
#include "../AuroraTypedefs.hpp"
#include "../AuroraUtils.hpp"
#if defined(_AUHAS_FMT)
#include <fmt/core.h>
#include <fmt/format.h>
#include <fmt/chrono.h>
#include <fmt/ranges.h>
#endif
#if !defined(_AUHAS_UUID)
#error Missing stduuid library
#endif
#include <uuid.h>
#define AUKN_SHARED_API(name, type, ...) AU_SHARED_API_EX(AUKN_SYM, name, type, ## __VA_ARGS__)
#if defined(_AURORA_RUNTIME_BUILD_API_INTERFACES)
#define AUKN_INTERFACE AUI_INTERFACE_IMPL
#else
#define AUKN_INTERFACE AUI_INTERFACE_FWD
#endif
#include "Memory/Memory.hpp"
#include "Console/Console.hpp"
#include "Crypto/Crypto.hpp"
#include "Compression/Compression.hpp"
#include "Data/Data.hpp"
#include "Debug/Debug.hpp"
#include "Hashing/Hashing.hpp"
#include "HWInfo/HWInfo.hpp"
#include "IO/IO.hpp"
#include "Locale/Locale.hpp"
#include "Parse/Parse.hpp"
#include "Process/Process.hpp"
#include "Processes/Processes.hpp"
#include "Registry/Registry.hpp"
#include "RNG/RNG.hpp"
#include "Telemetry/Telemetery.hpp"
#include "Threading/Threading.hpp"
#include "Async/Async.hpp"
#include "Time/Time.hpp"
#include "Loop/Loop.hpp"
namespace AuAsync = Aurora::Async;
namespace AuBuild = Aurora::Build;
namespace AuCompression = Aurora::Compression;
namespace AuConsole = Aurora::Console;
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 AuIO = Aurora::IO;
namespace AuIOFS = Aurora::IO::FS;
namespace AuIONet = Aurora::IO::Net;
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::Console::Logging;
namespace AuMemory = Aurora::Memory;
using AuWorkerId_t = AuAsync::WorkerId_t;
using AuWorkerPId_t = AuAsync::WorkerPId_t;
static inline void AuDebugBreak()
{
AuDebug::DebugBreak();
}
namespace Aurora
{
struct LocalLogInfo
{
bool enableLogging {true};
bool autoCompressOldLogs {false};
AuUInt32 maxSizeMB {128 * 1024 * 1024}; // these numbers feel insane, but at least we have a max threshold
int maxLogs {1024}; // by default, we neither leak disk space or waste opportunities of being able to dig through old data
#if defined(SHIP)
bool writeLogsToUserDir {true}; // use user directory
#else
bool writeLogsToUserDir {false}; // use cwd
#endif
};
struct TelemetryConfigDoc
{
LocalLogInfo localLogging;
bool enabled {false};
AuString address;
AuUInt16 port {45069};
AuString serviceIdnt {"7b5f7a54-7122-4489-ac1a-3d75884b307e"};
bool wantsActiveMonitoring {false};
bool privacyNoData {false};
bool privacyNoMod {false};
bool privacyNoLog {false};
bool privacyNoWarn {false};
bool alwaysCrashdump {true};
bool alwaysDisableCrashdump {false};
};
struct TelemetryConfig
{
bool readModNameJsonConfig {};
TelemetryConfigDoc defaultConfig;
};
struct SocketConsole
{
bool enableLogging {false};
bool binaryProto {false};
AuString path;
AuIONet::ConnectionEndpoint net;
};
struct ConsoleConfig
{
/// Enables Aurora::Console::xxxStd functions; defer to enableStdXX for default logger behaviour
bool enableStdPassthrough {false};
/// Enables standard, debug, and GUI consoles
bool enableConsole {true};
/// Attempt to force a terminal emulator host under graphical subsystems
bool forceConsoleWindow {};
/// Attempt to force a GUI console under command line targets
bool forceToolKitWindow {};
/// In conjunction with enableStdPassthrough, Aurora::Console::ReadStd reads a binary stream
/// In conjunction with !enableStdPassthrough, enables stdout logging
bool enableStdIn {true};
/// In conjunction with enableStdPassthrough, enables Aurora::Console::WriteStd to write binary, otherwise enables the console logger
/// In conjunction with !enableStdPassthrough, enables stdin cmd processing, otherwise disables stdin input
bool enableStdOut {true};
/// Use WxWidgets when possible
bool enableWxWidgets {true};
#if 1
/// FIO config
LocalLogInfo fio;
#endif
AuString titleBrand = "Aurora SDK Sample";
AuString supportPublic {"https://git.reece.sx/AuroraSupport/AuroraRuntime/issues"};
AuString supportInternal {"https://jira.reece.sx"};
};
struct LoggerConfig
{
///
bool enableStdIn {true};
///
bool enableStdOut {true};
/// FIO config
LocalLogInfo fileConfiguration;
/// Socket config
SocketConsole socketConfiguration;
};
struct CryptoConfig
{
/// Defer to the rationales in the implementation
bool allowChineseCerts {false};
/// Defer to the rationales in the implementation
bool allowRussianCerts {true};
/// WIP
bool allowHTTPRetrievalOfCerts {true};
///
bool enablePinning {true};
///
AuList<AuString> blacklistedCerts{};
AuList<AuString> whitelistedCerts{};
};
struct AsyncConfig
{
bool enableSchedularThread {true}; // turn this off to make your application lighter weight
AuUInt32 threadPoolDefaultStackSize {};
AuUInt32 schedularFrequency {2}; // * 0.5 or 1 MS depending on the platform
AuUInt32 sysPumpFrequency {25}; // x amount of schedularFrequencys
};
struct FIOConfig
{
/// You can bypass branding by assigning an empty string to 'defaultBrand'
AuString defaultBrand = "Aurora";
};
struct RuntimeStartInfo
{
ConsoleConfig console;
CryptoConfig crypto;
TelemetryConfig telemetry;
AsyncConfig async;
FIOConfig fio;
};
AUKN_SYM void RuntimeStart(const RuntimeStartInfo &info);
AUKN_SYM bool RuntimeHasStarted();
AUKN_SYM void RuntimeOverloadLocality(const AuPair<AuString, AuString> &locality);
AUKN_SYM void RuntimeShutdown();
AUKN_SYM void RuntimeSysPump();
}