diff --git a/Include/Aurora/Async/IWorkItemHandler.hpp b/Include/Aurora/Async/IWorkItemHandler.hpp index 0fa410b6..fe2f1fbd 100644 --- a/Include/Aurora/Async/IWorkItemHandler.hpp +++ b/Include/Aurora/Async/IWorkItemHandler.hpp @@ -29,8 +29,10 @@ namespace Aurora::Async EProcessNext type; AuList> waitFor; - AuUInt32 reschedMs; - AuUInt64 reschedNs; + AuUInt32 reschedMs {}; + AuUInt64 reschedNs {}; + AuUInt32 reschedClockAbsMs {}; + AuUInt64 reschedClockAbsNs {}; // @hideinitializer IThreadPool *pool; }; diff --git a/Include/Aurora/Async/Jobs.hpp b/Include/Aurora/Async/Jobs.hpp index 49704b0d..f782e1d3 100644 --- a/Include/Aurora/Async/Jobs.hpp +++ b/Include/Aurora/Async/Jobs.hpp @@ -18,8 +18,6 @@ namespace Aurora::Async AuFunction onSuccess; AuFunction onFailure; }; - - using FVoidJob = FJob; template struct CJob @@ -30,4 +28,6 @@ namespace Aurora::Async void(* onSuccess)(const Info_t &, const Result_t &); void(* onFailure)(const Info_t &); }; + + using FVoidJob = FJob; } \ No newline at end of file diff --git a/Include/Aurora/Async/WorkBasic.hpp b/Include/Aurora/Async/WorkBasic.hpp index 559ebf63..d384295d 100644 --- a/Include/Aurora/Async/WorkBasic.hpp +++ b/Include/Aurora/Async/WorkBasic.hpp @@ -12,44 +12,44 @@ namespace Aurora::Async /// --- THREAD POOL -- - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &> - static AuSPtr NewWork(const WorkerPId_t &worker, a task, b job, bool enableWait = false) + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr NewWork(const WorkerPId_tt &worker, a task, b job, bool enableWait = false) { return worker.pool->NewWorkItem(worker, AuMakeShared>(task, job), enableWait); } - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &> - static AuSPtr DispatchWork(const WorkerPId_t &worker, a task, b job, bool enableWait = false) + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr DispatchWork(const WorkerPId_tt &worker, a task, b job, bool enableWait = false) { return NewWork(worker, task, job, enableWait)->Dispatch(); } - template, typename Job_t = FJob, class a, class b, class c> - static AuSPtr NewWork(const WorkerPId_t &worker, a task, b job, c info, bool enableWait = false) + template, typename Job_t = FJob, class a, class b, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr NewWork(const WorkerPId_tt &worker, a task, b job, c info, bool enableWait = false) { return worker.pool->NewWorkItem(worker, AuMakeShared>(task, job, info), enableWait); } - template, typename Job_t = FJob, class a, class b, class c> - static AuSPtr DispatchWork(const WorkerPId_t &worker, a task, b job, c info, bool enableWait = false) + template, typename Job_t = FJob, class a, class b, class c, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr DispatchWork(const WorkerPId_tt &worker, a task, b job, c info, bool enableWait = false) { return NewWork(worker, task, job, info, enableWait)->Dispatch(); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &> - AuSPtr DispatchFunctional(const WorkerPId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + AuSPtr DispatchFunctional(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &> - AuSPtr DispatchFunctor(const WorkerPId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + AuSPtr DispatchFunctor(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &> - AuSPtr DispatchVoid(const WorkerPId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerPId_tt = WorkerPId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + AuSPtr DispatchVoid(const WorkerPId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromVoidVoid(task), job, inputParameters, enableWait); } @@ -57,44 +57,44 @@ namespace Aurora::Async /// --- ASYNC APP -- - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &> - static AuSPtr NewWork(const WorkerId_t &worker, a task, b job, bool enableWait = false) + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr NewWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false) { return NewWorkItem(worker, AuMakeShared>(task, job), enableWait); } - template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &> - static AuSPtr DispatchWork(const WorkerId_t &worker, a task, b job, bool enableWait = false) + template, typename Job_t = FJob, class a = const Job_t &, class b = Task_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr DispatchWork(const WorkerId_tt &worker, a task, b job, bool enableWait = false) { return NewWork(worker, task, job, enableWait)->Dispatch(); } - template, typename Job_t = FJob, class a, class b, class c> - static AuSPtr NewWork(const WorkerId_t &worker, a task, b job, c info, bool enableWait = false) + template, typename Job_t = FJob, class a, class b, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr NewWork(const WorkerId_tt &worker, a task, b job, c info, bool enableWait = false) { return NewWorkItem(worker, AuMakeShared>(task, job, info), enableWait); } - template, typename Job_t = FJob, class a, class b, class c> - static AuSPtr DispatchWork(const WorkerId_t &worker, a task, b job, c info, bool enableWait = false) + template, typename Job_t = FJob, class a, class b, class c, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + static AuSPtr DispatchWork(const WorkerId_tt &worker, a task, b job, c info, bool enableWait = false) { return NewWork(worker, task, job, info, enableWait)->Dispatch(); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &> - AuSPtr DispatchFunctional(const WorkerId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + AuSPtr DispatchFunctional(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &> - AuSPtr DispatchFunctor(const WorkerId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + AuSPtr DispatchFunctor(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromConsumerRefT(task), job, inputParameters, enableWait); } - - template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &> - AuSPtr DispatchVoid(const WorkerId_t &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) + + template, typename Job_t = FJob, typename ClazzImpl, class a = const Job_t &, class b = const Info_t &, class WorkerId_tt = WorkerId_t, AU_TEMPLATE_ENABLE_WHEN(std::is_same_v)> + AuSPtr DispatchVoid(const WorkerId_tt &worker, ClazzImpl task, a job, b inputParameters, bool enableWait = false) { return NewWork(worker, TaskFromVoidVoid(task), job, inputParameters, enableWait); } diff --git a/Include/Aurora/Async/WorkPairImpl.hpp b/Include/Aurora/Async/WorkPairImpl.hpp index da2ca95c..1f9dd0d3 100644 --- a/Include/Aurora/Async/WorkPairImpl.hpp +++ b/Include/Aurora/Async/WorkPairImpl.hpp @@ -227,8 +227,8 @@ namespace Aurora::Async private: - static constexpr bool IsCallbackPtr = std::is_pointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; - static constexpr bool IsTaskPtr = std::is_pointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; + static constexpr bool IsCallbackPtr = std::is_pointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; + static constexpr bool IsTaskPtr = std::is_pointer_v || AuIsBaseOfTemplate::value || AuIsBaseOfTemplate::value; //WorkerId_t caller; WorkerPId_t caller_; diff --git a/Source/Async/WorkItem.cpp b/Source/Async/WorkItem.cpp index e5f5ca32..fcf5f814 100644 --- a/Source/Async/WorkItem.cpp +++ b/Source/Async/WorkItem.cpp @@ -226,11 +226,19 @@ namespace Aurora::Async if (info.reschedMs) { SetSchedTime(info.reschedMs); - } - if (info.reschedNs) + } + else if (info.reschedNs) { SetSchedTimeNs(info.reschedNs); } + else if (info.reschedClockAbsMs) + { + SetSchedTimeAbs(info.reschedMs); + } + else if (info.reschedClockAbsNs) + { + SetSchedTimeNsAbs(info.reschedNs); + } WaitFor(info.waitFor); } diff --git a/Source/Console/Commands/Commands.cpp b/Source/Console/Commands/Commands.cpp index 92a90f9d..ed5fc364 100644 --- a/Source/Console/Commands/Commands.cpp +++ b/Source/Console/Commands/Commands.cpp @@ -110,7 +110,7 @@ namespace Aurora::Console::Commands { dispatch.callback->OnCommand(dispatch.arguments); }), - {}, + AuAsync::FJob{}, CommandDispatch(res.result, callback), false );