7#ifndef _THREAD_CLASS_HEADER_
8#define _THREAD_CLASS_HEADER_
19#define __STDCALL __stdcall
26#ifndef __THREAD_RESULT
28#define __THREAD_RESULT unsigned long
30#define __THREAD_RESULT void*
36#define _DEBUG_NAME_SIZE 512
41#define __THREADCALL __stdcall
57#define A_UTILS_THREAD_PRIORITY_LOWEST 0.0
59#define A_UTILS_THREAD_PRIORITY_LOW 0.25
61#define A_UTILS_THREAD_PRIORITY_NORMAL 0.5
63#define A_UTILS_THREAD_PRIORITY_HIGH 0.625
65#define A_UTILS_THREAD_PRIORITY_HIGHEST 0.75
67#define A_UTILS_THREAD_PRIORITY_TIME_CRITICAL 1.0
207template <
typename Callable,
typename ...Args>
211 pFunc(std::forward<Args>(args)...);
221template <
typename Callable,
typename ...Args>
226 pFunc(std::forward<Args>(args)...);
236 std::function<
void()> pFunc);
246template <
typename Callable,
typename ...Args>
249 Callable&& pFunc, Args&&... args)
253 auto pFuncCallable = std::bind(std::forward<Callable>(pFunc), std::forward<Args>(args)...);
264template <
typename Callable,
typename ...Args>
266 Callable&& pFunc, Args&&... args)
270 std::forward<Callable>(pFunc),
271 std::forward<Args>(args)...);
unsigned long tUInt32
type definition for unsigned integer values (32bit) (platform and compiler independent type).
double tFloat64
type definition for Float64 (64bit double values) (platform and compiler independent type).
A_UTILS_NS::cResult tResult
For backwards compatibility and to bring latest version into scope.
#define IS_OK(s)
Check if result is OK.
ADTF A_UTIL Namespace - Within adtf this is used as util or adtf_util.
tResult get_cpu_affinity(std::thread::native_handle_type oThreadHandle, tCpuAffinityMask &oCpuAffinity)
Gets the CPU affinity of a thread.
std::thread::native_handle_type get_native_handle_of_this_thread()
Get the native handle for the current thread.
tSchedulingClass
Enum for different scheduling schemes.
@ Default
Choose whatever is applicable.
@ Normal
Basic non-realtime scheduling.
@ RealTime
Realtime scheduling.
tResult set_priority(std::thread::native_handle_type oThreadHandle, tSchedulingClass eSchedulingClass, tFloat64 fPriority)
Sets the priority of a thread.
tResult create_thread_with_scheduling(std::thread &oThread, const tSchedulingParameters &sScheduling, Callable &&pFunc, Args &&... args)
Creates a new thread that has the given scheduling parameters.
tResult get_scheduling(const std::thread::native_handle_type &oThreadHandle, tSchedulingParameters &sScheduling)
Gets the scheduling parameters of a thread.
tResult set_cpu_affinity(std::thread::native_handle_type oThreadHandle, const tCpuAffinityMask &oCpuAffinity)
Sets the CPU affinity of a thread.
std::vector< bool > tCpuAffinityMask
Container for a CPU Affinity mask.
tResult set_scheduling(std::thread::native_handle_type oThreadHandle, const tSchedulingParameters &sScheduling)
Sets the scheduling parameters of a thread.
tResult create_thread_with_scheduling_impl(std::thread &oThread, const tSchedulingParameters &sScheduling, std::function< void()> pFunc)
For internal use only.
void run_with_checked_scheduling(tSchedulingParameters sScheduling, Callable &&pFunc, Args &&... args)
Sets the given scheduling paremeters and executes the given method afterwards only if the scheduling ...
tResult get_priority(std::thread::native_handle_type oThreadHandle, tSchedulingClass &eSchedulingClass, tFloat64 &fPriority)
Gets the priority of a thread.
void run_with_scheduling(tSchedulingParameters sScheduling, Callable &&pFunc, Args &&... args)
Sets the given scheduling paremeters and executes the given method afterwards.
Compound class, that groups scheduling parameters.
tCpuAffinityMask oCpuAffinity
The CPU affinity. Empty -> run on all CPUs.
tSchedulingClass eSchedulingClass
The scheduling class.
bool operator==(const tSchedulingParameters &sOther) const
Equals operator.
tSchedulingParameters(const tSchedulingParameters &)=default
Copy constructor.
tSchedulingParameters(tSchedulingParameters &&)=default
Move constructor.
tSchedulingParameters(tSchedulingClass eSchedulingClass, tFloat64 fPriority)
Convenience constructor.
tFloat64 fPriority
The priority in the range [0.0, 1.0].
tSchedulingParameters()
Constructor.
tSchedulingParameters(tSchedulingClass eSchedulingClass, tFloat64 fPriority, const tCpuAffinityMask &oCpuAffinity)
Convenience constructor.