G.O.D - Grand Object-bound Dispatcher
G.O.D is a high performance non-blocking task dispatcher which guarantees class member functions’ execution sequence
// First, you can attach G.O.D (AsyncExecutable) to an object like this:
class TestObject : public AsyncExecutable
{
public:
void TestFunc(double a, int b)
{
// do something...
// (e.g.) someobj->DoAsync(...);
}
// ... ...
};
// somewhere ...
auto testobj = std::make_shared<TestObject>(); ///< new TestObject;
// And then, make your own worker thread which implements Runnable::Run() like this:
class TestWorkerThread : public Runnable
{
public:
virtual bool Run()
{
// Now, you can call a member function like this:
testobj->DoAsync(&TestObject::TestFunc, 100.123, 456);
// or, deferred execution 1000ms later like this:
testobj->DoAsyncAfter(1000, &TestObject::TestFunc, 100.123, 456);
// ... ...
}
};
// Lastly, run worker-threads at the main() function
JobDispatcher<TestWorkerThread> workerService(WORKER_COUNT);
workerService.RunWorkerThreads();
For more information, just see self-explaning DispatcherTest.cpp