From a6f88dff57bb1523b221f7fab4feeea1079be18a Mon Sep 17 00:00:00 2001 From: dev0 Date: Sat, 29 Nov 2025 09:45:08 +0530 Subject: [PATCH] Fixes --- CMakeLists.txt | 8 ++--- Src/IACore/imp/cpp/AsyncOps.cpp | 6 ++++ Src/IACore/imp/cpp/IACore.cpp | 3 +- Src/IACore/inc/IACore/Logger.hpp | 52 ++++++++++++++++---------------- 4 files changed, 38 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 01e92d4..91bc781 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -64,9 +64,9 @@ if(IACore_BUILD_TESTS) add_subdirectory(Tests) endif() -# ------------------------------------------------- +# ------------------------------------------------------------ # Local Development Sandboxes (not included in source control) -# ------------------------------------------------- -if (EXISTS ".local") - add_subdirectory(.local) +# ------------------------------------------------------------ +if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.local") + add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/.local") endif() diff --git a/Src/IACore/imp/cpp/AsyncOps.cpp b/Src/IACore/imp/cpp/AsyncOps.cpp index 409c377..b07c7ce 100644 --- a/Src/IACore/imp/cpp/AsyncOps.cpp +++ b/Src/IACore/imp/cpp/AsyncOps.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include #include namespace IACore @@ -31,6 +32,7 @@ namespace IACore VOID AsyncOps::InitializeScheduler(IN UINT8 workerCount) { + IA_RELEASE_ASSERT(IACore::IsMainThread()); if (!workerCount) workerCount = std::max((UINT32) 2, std::thread::hardware_concurrency() - 2); for (UINT32 i = 0; i < workerCount; i++) @@ -39,6 +41,8 @@ namespace IACore VOID AsyncOps::TerminateScheduler() { + IA_RELEASE_ASSERT(IACore::IsMainThread()); + for (auto &w : s_scheduleWorkers) { w.request_stop(); @@ -60,6 +64,7 @@ namespace IACore VOID AsyncOps::ScheduleTask(IN Function task, IN Schedule *schedule, IN Priority priority) { IA_ASSERT(s_scheduleWorkers.size() && "Scheduler must be initialized before calling this function"); + IA_RELEASE_ASSERT(IACore::IsMainThread()); schedule->Counter.fetch_add(1); { @@ -75,6 +80,7 @@ namespace IACore VOID AsyncOps::WaitForScheduleCompletion(IN Schedule *schedule) { IA_ASSERT(s_scheduleWorkers.size() && "Scheduler must be initialized before calling this function"); + IA_RELEASE_ASSERT(IACore::IsMainThread()); while (schedule->Counter.load() > 0) { diff --git a/Src/IACore/imp/cpp/IACore.cpp b/Src/IACore/imp/cpp/IACore.cpp index bd2edf8..4658b40 100644 --- a/Src/IACore/imp/cpp/IACore.cpp +++ b/Src/IACore/imp/cpp/IACore.cpp @@ -33,6 +33,7 @@ namespace IACore VOID Terminate() { + IA_RELEASE_ASSERT(IsMainThread()); Logger::Terminate(); } @@ -43,7 +44,7 @@ namespace IACore FLOAT64 GetSecondsCount() { - return (HRClock::now() - g_startTime).count(); + return (FLOAT64) GetTicksCount() / 1000.0; } UINT32 GetRandom(IN UINT32 seed) diff --git a/Src/IACore/inc/IACore/Logger.hpp b/Src/IACore/inc/IACore/Logger.hpp index cb5bd3d..a3b8bbe 100644 --- a/Src/IACore/inc/IACore/Logger.hpp +++ b/Src/IACore/inc/IACore/Logger.hpp @@ -1,16 +1,16 @@ -// IACore-OSS; The Core Library for All IA Open Source Projects +// IACore-OSS; The Core Library for All IA Open Source Projects // Copyright (C) 2025 IAS (ias@iasoft.dev) -// +// // This program is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program. If not, see . @@ -56,7 +56,27 @@ namespace IACore } private: -#if IA_ENABLE_LOGGING > 0 +#if IA_DISABLE_LOGGING > 0 + STATIC VOID LogStatus(IN String &&msg) + { + UNUSED(msg); + } + + STATIC VOID LogInfo(IN String &&msg) + { + UNUSED(msg); + } + + STATIC VOID LogWarn(IN String &&msg) + { + UNUSED(msg); + } + + STATIC VOID LogError(IN String &&msg) + { + UNUSED(msg); + } +#else STATIC VOID LogStatus(IN String &&msg) { if (s_logLevel <= ELogLevel::VERBOSE) @@ -80,26 +100,6 @@ namespace IACore if (s_logLevel <= ELogLevel::ERROR) LogInternal(__CC_RED, "ERROR", IA_MOVE(msg)); } -#else - STATIC VOID LogStatus(IN String &&msg) - { - UNUSED(msg); - } - - STATIC VOID LogInfo(IN String &&msg) - { - UNUSED(msg); - } - - STATIC VOID LogWarn(IN String &&msg) - { - UNUSED(msg); - } - - STATIC VOID LogError(IN String &&msg) - { - UNUSED(msg); - } #endif STATIC VOID LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String &&msg); @@ -114,4 +114,4 @@ namespace IACore friend VOID Initialize(); friend VOID Terminate(); }; -} \ No newline at end of file +} // namespace IACore \ No newline at end of file