The cpp file with this example: scheduler.cpp. The active object design pattern gives the possibility to run the commands synchronously or asynchronously, it use the thread pool (from boost::thread) and command queue.
#include <mt4cpp/Command.hpp> using namespace mt4cpp; struct DummyCmd : public Command { DummyCmd() {} virtual ~DummyCmd() {} virtual void operator()(Progress& progress) { progress.setProgress(0.5); //send the message about the progress } };The command should be executed asynchronously (in another thread, the calling thread will not wait for finish):
#include <mt4cpp/Scheduler.hpp> using namespace mt4cpp; Scheduler scheduler(1); PCommand cmd(new DummyCmd ); scheduler.executeAsynchronously( cmd );or synchronously (the command is executed in another thread, but the calling thread is waiting for finish or break the command)
scheduler.executeSynchronously( cmd );The argument of Scheduler constructor is a number of threads in the pool.