This is some code i'm using in Java for Making Asynchronous function calls in Java :
public class AsyncLogger
{
public static asyncLog = null;
public static ExecutorService executorService = Executors.newSingleThreadExecutor();
public static AsyncLogger GetAsyncClass()
{
if(asyncLog == null)
{
asyncLog= new AsyncLogger();
}
return asyncLog;
}
public void WriteLog(String logMesg)
{
executorService.execute(new Runnable()
{
public void run()
{
WriteLogDB(logMesg);
}
});
}
public void ShutDownAsync()
{
executorService.shutdown();
}
}
This is a Singleton Class with static ExecutorService and WriteLogDB will be called as an Asynchronous function. So i can process my Code in WriteLogDB asynchronously without affecting the main flow.
Can i get a C++ equivalent like this ..?