commonlib
functionthread.h
Go to the documentation of this file.
1 
10 #pragma once
11 
12 #include "threadex.h"
13 #include <functional>
14 
15 BEGIN_NAMESPACE_THREADING
16 
20 class FunctionThread : public ThreadEx
21 {
22 public:
23  using CallbackFunction = std::function<void(void)>;
24 
29  FunctionThread(CallbackFunction callback = nullptr);
30 
35  const CallbackFunction& getCallback() const;
36 
41  void setCallback(const CallbackFunction& value);
42 
43 protected:
44  void execute() override;
45 
46 private:
47  CallbackFunction callback;
48 };
49 
50 END_NAMESPACE_THREADING
void execute() override
Provides an abstract or pure virtual method to contain the code which executes when the thread is run...
Provides a mechanism for executing a method in a thread.
Definition: functionthread.h:20
ThreadEx class for working with threads.
Definition: threadex.h:46
FunctionThread(CallbackFunction callback=nullptr)
Initializes a new instance of the FunctionThread class.
const CallbackFunction & getCallback() const
Get callback function.
ThreadEx is an abstract class that enables creation of separate threads of execution in an applicatio...
void setCallback(const CallbackFunction &value)
Set callback function.