Compare commits
2 Commits
cf18f0d55c
...
2fb1e9032b
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fb1e9032b | |||
| a6f88dff57 |
@ -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()
|
||||
|
||||
@ -14,6 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
#include <IACore/IACore.hpp>
|
||||
#include <IACore/AsyncOps.hpp>
|
||||
|
||||
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<VOID()> 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)
|
||||
{
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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 <https://www.gnu.org/licenses/>.
|
||||
|
||||
@ -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();
|
||||
};
|
||||
}
|
||||
} // namespace IACore
|
||||
@ -269,6 +269,15 @@
|
||||
|
||||
#define IA_UNREACHABLE(msg) IA_RELEASE_ASSERT_MSG(FALSE, "Unreachable code: " msg)
|
||||
|
||||
#define IA_TRY_PURE(expr) \
|
||||
{ \
|
||||
auto _ia_res = (expr); \
|
||||
if (!_ia_res) \
|
||||
{ \
|
||||
return tl::make_unexpected(std::move(_ia_res.error())); \
|
||||
} \
|
||||
}
|
||||
|
||||
#define IA_TRY(expr) \
|
||||
__extension__({ \
|
||||
auto _ia_res = (expr); \
|
||||
@ -540,6 +549,7 @@ template<typename _value_type> using UniquePtr = std::unique_ptr<_value_type>;
|
||||
template<typename _value_type> using Deque = std::deque<_value_type>;
|
||||
template<typename _type_a, typename _type_b> using Pair = std::pair<_type_a, _type_b>;
|
||||
template<typename... types> using Tuple = std::tuple<types...>;
|
||||
template<typename _key_type, typename _value_type> using KeyValuePair = std::pair<_key_type, _value_type>;
|
||||
|
||||
template<typename _expected_type, typename _unexpected_type>
|
||||
using Expected = tl::expected<_expected_type, _unexpected_type>;
|
||||
|
||||
Reference in New Issue
Block a user