3#include "pthread_wrapper.hpp"
4#include "thread_registry.hpp"
5#include "thread_wrapper.hpp"
11namespace threadschedule
23class ThreadWrapperReg :
public ThreadWrapper
26 ThreadWrapperReg() =
default;
28 ThreadWrapperReg(ThreadWrapperReg&&)
noexcept =
default;
29 auto operator=(ThreadWrapperReg&&)
noexcept -> ThreadWrapperReg& =
default;
31 ThreadWrapperReg(ThreadWrapperReg
const&) =
delete;
32 auto operator=(ThreadWrapperReg
const&) -> ThreadWrapperReg& =
delete;
34 template <
typename F,
typename... Args>
35 explicit ThreadWrapperReg(std::string name, std::string componentTag, F&& f, Args&&... args)
37 [n = std::move(name), c = std::move(componentTag), func = std::forward<F>(f)](
auto&&... inner) {
39 std::invoke(func, std::forward<
decltype(inner)>(inner)...);
41 std::forward<Args>(args)...)
46#if __cplusplus >= 202002L || (defined(_MSVC_LANG) && _MSVC_LANG >= 202002L)
56class JThreadWrapperReg :
public JThreadWrapper
59 JThreadWrapperReg() =
default;
61 JThreadWrapperReg(JThreadWrapperReg&&) noexcept = default;
62 auto operator=(JThreadWrapperReg&&) noexcept -> JThreadWrapperReg& = default;
64 JThreadWrapperReg(JThreadWrapperReg const&) = delete;
65 auto operator=(JThreadWrapperReg const&) -> JThreadWrapperReg& = delete;
67 template <typename F, typename... Args>
68 explicit JThreadWrapperReg(std::
string name, std::
string componentTag, F&& f, Args&&... args)
70 [n = std::move(name), c = std::move(componentTag),
71 func = std::forward<F>(f)](std::stop_token st, auto&&... inner) {
73 if constexpr (std::is_invocable_v<
decltype(func), std::stop_token,
75 std::invoke(func, std::move(st), std::forward<
decltype(inner)>(inner)...);
76 else if constexpr (std::is_invocable_v<
decltype(func),
decltype(inner)...,
78 std::invoke(func, std::forward<
decltype(inner)>(inner)..., std::move(st));
80 std::invoke(func, std::forward<
decltype(inner)>(inner)...);
82 std::forward<Args>(args)...)
96class PThreadWrapperReg :
public PThreadWrapper
99 PThreadWrapperReg() =
default;
101 PThreadWrapperReg(PThreadWrapperReg&&)
noexcept =
default;
102 auto operator=(PThreadWrapperReg&&)
noexcept -> PThreadWrapperReg& =
default;
104 PThreadWrapperReg(PThreadWrapperReg
const&) =
delete;
105 auto operator=(PThreadWrapperReg
const&) -> PThreadWrapperReg& =
delete;
107 template <
typename F,
typename... Args>
108 explicit PThreadWrapperReg(std::string name, std::string componentTag, F&& f, Args&&... args)
110 [n = std::move(name), c = std::move(componentTag), func = std::forward<F>(f)](
auto&&... inner) {
112 std::invoke(func, std::forward<
decltype(inner)>(inner)...);
114 std::forward<Args>(args)...)
RAII guard that registers the current thread on construction and unregisters it on destruction.