diff --git a/dll/commdll.dll b/dll/commdll.dll index 47fc1d6..4e17394 100644 Binary files a/dll/commdll.dll and b/dll/commdll.dll differ diff --git a/dll/commdllD.dll b/dll/commdllD.dll index bc56888..ece5c41 100644 Binary files a/dll/commdllD.dll and b/dll/commdllD.dll differ diff --git a/dll/iodll.dll b/dll/iodll.dll index fda59a7..a8e5fa7 100644 Binary files a/dll/iodll.dll and b/dll/iodll.dll differ diff --git a/dll/iodllD.dll b/dll/iodllD.dll index 958a308..718ba52 100644 Binary files a/dll/iodllD.dll and b/dll/iodllD.dll differ diff --git a/dll/mcctrdll.dll b/dll/mcctrdll.dll index 8faeb15..f89f39d 100644 Binary files a/dll/mcctrdll.dll and b/dll/mcctrdll.dll differ diff --git a/dll/mcctrdllD.dll b/dll/mcctrdllD.dll index fde1964..d4b4943 100644 Binary files a/dll/mcctrdllD.dll and b/dll/mcctrdllD.dll differ diff --git a/dll/secsgemdll.dll b/dll/secsgemdll.dll index 0108673..d008444 100644 Binary files a/dll/secsgemdll.dll and b/dll/secsgemdll.dll differ diff --git a/dll/secsgemdllD.dll b/dll/secsgemdllD.dll index 4d27bdc..e42e5c6 100644 Binary files a/dll/secsgemdllD.dll and b/dll/secsgemdllD.dll differ diff --git a/dll/utility.dll b/dll/utility.dll index 1ab6557..cdebb40 100644 Binary files a/dll/utility.dll and b/dll/utility.dll differ diff --git a/dll/utilityD.dll b/dll/utilityD.dll index b4130c2..0ef1847 100644 Binary files a/dll/utilityD.dll and b/dll/utilityD.dll differ diff --git a/utility/Include/RunnerTask.h b/utility/Include/RunnerTask.h new file mode 100644 index 0000000..e83eb6f --- /dev/null +++ b/utility/Include/RunnerTask.h @@ -0,0 +1,90 @@ +#pragma once +#include +#include +#include +#include +#include +#include +#include +#include + +#include "DllDefines.h" + +/* +* @link : https://www.cppstories.com/2019/12/threading-loopers-cpp17/ +*/ + +using Runnable = std::function; + +class UTILITYDLL CRunnerTask +{ + // dispatch class +public: + using Runnable = std::function; + class CDispatcher + { + friend class CRunnerTask; // Allow the looper to access the private constructor. + + public: + // Yet to be defined method, which will post the runnable + // into the looper-queue. + bool post(CRunnerTask::Runnable&& aRunnable) + { + return mAssignedRunner.post(std::move(aRunnable)); + } + + private: // construction, since we want the looper to expose it's dispatcher exclusively! + CDispatcher(CRunnerTask& aLooper) + : mAssignedRunner(aLooper) + {} + + private: + // Store a reference to the attached looper in order to + // emplace tasks into the queue. + CRunnerTask& mAssignedRunner; + }; + + // ctor + CRunnerTask(); + // Copy denied, Move to be implemented + + ~CRunnerTask(); + + // To be called, once the runner should start looping. + bool run(); + + void stop(); + + bool running() const; + + Runnable next(); + + std::shared_ptr getDispatcher() + { + return mDispatcher; + } + + +private: + // Conditionally-infinite loop doing sth. iteratively + void runFunc(); + + // Shared implementation of exiting the loop-function and joining +// to the main thread. + void abortAndJoin(); + + bool post(Runnable&& aRunnable); + + // attributes + std::thread mThread; + + std::atomic_bool mRunning; + std::atomic_bool mAbortRequested; + + // + std::recursive_mutex mRunnablesMutex; + std::queue mRunnables; + + std::shared_ptr mDispatcher; +}; + diff --git a/utility/lib/utility.lib b/utility/lib/utility.lib index d49a690..c2c3c7c 100644 Binary files a/utility/lib/utility.lib and b/utility/lib/utility.lib differ diff --git a/utility/lib/utilityD.lib b/utility/lib/utilityD.lib index 5e9e437..12584ce 100644 Binary files a/utility/lib/utilityD.lib and b/utility/lib/utilityD.lib differ