30 class ProcessingHandler
33 ProcessingHandler() {}
36 if (async_thread.joinable())
41 bool is_processing =
false;
42 std::mutex is_processing_mtx;
49 std::thread async_thread;
57 is_processing_mtx.lock();
59 is_processing_mtx.unlock();
61 is_processing_mtx.lock();
62 is_processing =
false;
63 is_processing_mtx.unlock();
72 is_processing_mtx.lock();
74 is_processing_mtx.unlock();
83 is_processing_mtx.lock();
84 bool s = is_processing;
85 is_processing_mtx.unlock();
94 is_processing_mtx.lock();
95 if (is_processing && async_thread.joinable())
97 printf(
"ALREADY PROCESSING!!!!\n");
98 is_processing_mtx.unlock();
101 is_processing_mtx.unlock();
107 catch (std::exception &e)
111 is_processing_mtx.lock();
112 is_processing =
true;
113 is_processing_mtx.unlock();
114 auto fun = [
this]() {
process(); };
115 async_thread = std::thread(fun);
bool get_is_processing()
Get the processing status externally.
Definition processing_handler.h:81
void set_is_processing(bool v)
Set the processing status externally, to force waiting before starting a new thread.
Definition processing_handler.h:70
void process()
Performing processing. This is not multi-threaded, intended to call it externally.
Definition processing_handler.h:55
virtual void do_process()=0
Actual processing function to be implemented by the child class.
void asyncProcess()
Perform processing asynchronously, in a thread.
Definition processing_handler.h:92