Compare commits
2 Commits
cf18f0d55c
...
2fb1e9032b
| Author | SHA1 | Date | |
|---|---|---|---|
| 2fb1e9032b | |||
| a6f88dff57 |
@ -64,9 +64,9 @@ if(IACore_BUILD_TESTS)
|
|||||||
add_subdirectory(Tests)
|
add_subdirectory(Tests)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# -------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Local Development Sandboxes (not included in source control)
|
# Local Development Sandboxes (not included in source control)
|
||||||
# -------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
if (EXISTS ".local")
|
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.local")
|
||||||
add_subdirectory(.local)
|
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/.local")
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include <IACore/IACore.hpp>
|
||||||
#include <IACore/AsyncOps.hpp>
|
#include <IACore/AsyncOps.hpp>
|
||||||
|
|
||||||
namespace IACore
|
namespace IACore
|
||||||
@ -31,6 +32,7 @@ namespace IACore
|
|||||||
|
|
||||||
VOID AsyncOps::InitializeScheduler(IN UINT8 workerCount)
|
VOID AsyncOps::InitializeScheduler(IN UINT8 workerCount)
|
||||||
{
|
{
|
||||||
|
IA_RELEASE_ASSERT(IACore::IsMainThread());
|
||||||
if (!workerCount)
|
if (!workerCount)
|
||||||
workerCount = std::max((UINT32) 2, std::thread::hardware_concurrency() - 2);
|
workerCount = std::max((UINT32) 2, std::thread::hardware_concurrency() - 2);
|
||||||
for (UINT32 i = 0; i < workerCount; i++)
|
for (UINT32 i = 0; i < workerCount; i++)
|
||||||
@ -39,6 +41,8 @@ namespace IACore
|
|||||||
|
|
||||||
VOID AsyncOps::TerminateScheduler()
|
VOID AsyncOps::TerminateScheduler()
|
||||||
{
|
{
|
||||||
|
IA_RELEASE_ASSERT(IACore::IsMainThread());
|
||||||
|
|
||||||
for (auto &w : s_scheduleWorkers)
|
for (auto &w : s_scheduleWorkers)
|
||||||
{
|
{
|
||||||
w.request_stop();
|
w.request_stop();
|
||||||
@ -60,6 +64,7 @@ namespace IACore
|
|||||||
VOID AsyncOps::ScheduleTask(IN Function<VOID()> task, IN Schedule *schedule, IN Priority priority)
|
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_ASSERT(s_scheduleWorkers.size() && "Scheduler must be initialized before calling this function");
|
||||||
|
IA_RELEASE_ASSERT(IACore::IsMainThread());
|
||||||
|
|
||||||
schedule->Counter.fetch_add(1);
|
schedule->Counter.fetch_add(1);
|
||||||
{
|
{
|
||||||
@ -75,6 +80,7 @@ namespace IACore
|
|||||||
VOID AsyncOps::WaitForScheduleCompletion(IN Schedule *schedule)
|
VOID AsyncOps::WaitForScheduleCompletion(IN Schedule *schedule)
|
||||||
{
|
{
|
||||||
IA_ASSERT(s_scheduleWorkers.size() && "Scheduler must be initialized before calling this function");
|
IA_ASSERT(s_scheduleWorkers.size() && "Scheduler must be initialized before calling this function");
|
||||||
|
IA_RELEASE_ASSERT(IACore::IsMainThread());
|
||||||
|
|
||||||
while (schedule->Counter.load() > 0)
|
while (schedule->Counter.load() > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -33,6 +33,7 @@ namespace IACore
|
|||||||
|
|
||||||
VOID Terminate()
|
VOID Terminate()
|
||||||
{
|
{
|
||||||
|
IA_RELEASE_ASSERT(IsMainThread());
|
||||||
Logger::Terminate();
|
Logger::Terminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ namespace IACore
|
|||||||
|
|
||||||
FLOAT64 GetSecondsCount()
|
FLOAT64 GetSecondsCount()
|
||||||
{
|
{
|
||||||
return (HRClock::now() - g_startTime).count();
|
return (FLOAT64) GetTicksCount() / 1000.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT32 GetRandom(IN UINT32 seed)
|
UINT32 GetRandom(IN UINT32 seed)
|
||||||
|
|||||||
@ -56,7 +56,27 @@ namespace IACore
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
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)
|
STATIC VOID LogStatus(IN String &&msg)
|
||||||
{
|
{
|
||||||
if (s_logLevel <= ELogLevel::VERBOSE)
|
if (s_logLevel <= ELogLevel::VERBOSE)
|
||||||
@ -80,26 +100,6 @@ namespace IACore
|
|||||||
if (s_logLevel <= ELogLevel::ERROR)
|
if (s_logLevel <= ELogLevel::ERROR)
|
||||||
LogInternal(__CC_RED, "ERROR", IA_MOVE(msg));
|
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
|
#endif
|
||||||
|
|
||||||
STATIC VOID LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String &&msg);
|
STATIC VOID LogInternal(IN PCCHAR prefix, IN PCCHAR tag, IN String &&msg);
|
||||||
@ -114,4 +114,4 @@ namespace IACore
|
|||||||
friend VOID Initialize();
|
friend VOID Initialize();
|
||||||
friend VOID Terminate();
|
friend VOID Terminate();
|
||||||
};
|
};
|
||||||
}
|
} // namespace IACore
|
||||||
@ -269,6 +269,15 @@
|
|||||||
|
|
||||||
#define IA_UNREACHABLE(msg) IA_RELEASE_ASSERT_MSG(FALSE, "Unreachable code: " msg)
|
#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) \
|
#define IA_TRY(expr) \
|
||||||
__extension__({ \
|
__extension__({ \
|
||||||
auto _ia_res = (expr); \
|
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 _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 _type_a, typename _type_b> using Pair = std::pair<_type_a, _type_b>;
|
||||||
template<typename... types> using Tuple = std::tuple<types...>;
|
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>
|
template<typename _expected_type, typename _unexpected_type>
|
||||||
using Expected = tl::expected<_expected_type, _unexpected_type>;
|
using Expected = tl::expected<_expected_type, _unexpected_type>;
|
||||||
|
|||||||
Reference in New Issue
Block a user