Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ThreadClosure.h
Go to the documentation of this file.
1#pragma once
2#include <misc/gen/Thread.h>
3
4namespace sf
5{
33 : public Thread
34 , public TClosure<int, Thread&>
35{
36 public:
40 ThreadClosure(const std::string& name = "")
41 : Thread(name)
42 , TClosure<int, Thread&>()
43 {}
44
50 explicit ThreadClosure(const func_type& func, const std::string& name = "")
51 : Thread(name)
52 , TClosure<int, Thread&>(func)
53 {}
54
55 protected:
59 int run() override
60 {
61 return isAssigned() ? call(*this) : 0;
62 }
63};
64
65}// namespace sf
Encapsulates the std::function() template.
Definition TClosure.h:14
std::function< int(Args...)> func_type
Function type of the lambda or function.
Definition TClosure.h:19
int call(Args... args) const
Makes the call to the member function.
bool isAssigned() const
Checks if the closure is valid for calling.
Class which combines a thread class and closure template.
Definition ThreadClosure.h:35
ThreadClosure(const func_type &func, const std::string &name="")
Thread run function assigment constructor.
Definition ThreadClosure.h:50
int run() override
Definition ThreadClosure.h:59
ThreadClosure(const std::string &name="")
Default constructor.
Definition ThreadClosure.h:40
Thread wrapper class to be used for attachment to an existing thread or a new to be created thread....
Definition Thread.h:28
Definition Application.h:10