The worker thread class receives delegated tasks in an independent thread.
It is a very useful module extracted from the cpp-tbox project, which can be used independently after excluding functions related to other modules of cpp-tbox.
The source code corresponding to cpp-tbox:work_thread.h,work_thread.cpp
Copy work_thread.cpp and work_thread.h under src/ to your project, and compile them together with normal code.
#include "work_thread.h"
...
hevake::WorkThread worker;
...
worker.execute([]{ DoSomethingByWorker(); });
...
See Demo
This module is just a little part of cpp-tbox。 There are many more useful modules out there.
Click here to go to: cpp-tbox。
We would be happy if you could give us a star.