zpp
Zephyr C++20 Framework
zpp::thread_attr Class Reference

Thread creation attributes. More...

#include <thread_attr.hpp>

Public Member Functions

 thread_attr (const thread_attr &) noexcept=default
 
 thread_attr (thread_attr &&) noexcept=default
 
thread_attroperator= (const thread_attr &) noexcept=default
 
thread_attroperator= (thread_attr &&) noexcept=default
 
template<class ... T_Args>
constexpr thread_attr (T_Args &&... args) noexcept
 Constructor taking a variable number of attributes. More...
 
template<class T_FirstArg , class ... T_Args>
constexpr void set (T_FirstArg &&first, T_Args &&... rest) noexcept
 
constexpr void set () const noexcept
 
constexpr void set (thread_prio prio) noexcept
 Set the thread priority. More...
 
template<class T_Rep , class T_Period >
constexpr void set (const thread_start_delay< T_Rep, T_Period > &delay) noexcept
 Set the thread start delay. More...
 
constexpr void set (thread_suspend v) noexcept
 Set the thread start suspended flag. More...
 
constexpr void set (thread_essential v) noexcept
 Set the thread essential flag. More...
 
constexpr void set (thread_user v) noexcept
 Set the thread user flag. More...
 
constexpr void set (thread_inherit_perms v) noexcept
 Set the thread inherit permisions flag. More...
 
constexpr void set (thread_fp_regs v) noexcept
 Set the thread FP regs flag. More...
 
constexpr void set (thread_sse_regs v) noexcept
 Set the thread SSE regs flag. More...
 
constexpr auto native_delay () const noexcept
 get the Zephyr native delay value More...
 
constexpr auto native_prio () const noexcept
 get the Zephyr native priority value More...
 
constexpr auto native_options () const noexcept
 get the Zephyr native options value More...
 

Detailed Description

Thread creation attributes.

Definition at line 35 of file thread_attr.hpp.

Constructor & Destructor Documentation

◆ thread_attr() [1/3]

zpp::thread_attr::thread_attr ( const thread_attr )
defaultnoexcept

◆ thread_attr() [2/3]

zpp::thread_attr::thread_attr ( thread_attr &&  )
defaultnoexcept

◆ thread_attr() [3/3]

template<class ... T_Args>
constexpr zpp::thread_attr::thread_attr ( T_Args &&...  args)
inlineexplicitconstexprnoexcept

Constructor taking a variable number of attributes.

Contructor that initializes the thread creation attributes based on the args arguments being passed. The order of the arguments does not matter. Arguments must be of a Type that has a coresponding set(Type) function.

Parameters
argsThe attributes to set.

Definition at line 53 of file thread_attr.hpp.

54  {
55  set(std::forward<T_Args>(args)...);
56  }
constexpr void set() const noexcept
Definition: thread_attr.hpp:65

References set().

Member Function Documentation

◆ native_delay()

constexpr auto zpp::thread_attr::native_delay ( ) const
inlineconstexprnoexcept

get the Zephyr native delay value

Returns
The native delay value

Definition at line 194 of file thread_attr.hpp.

195  {
196  return m_delay;
197  }

◆ native_options()

constexpr auto zpp::thread_attr::native_options ( ) const
inlineconstexprnoexcept

get the Zephyr native options value

Returns
The native options value

Definition at line 214 of file thread_attr.hpp.

215  {
216  return m_options;
217  }

◆ native_prio()

constexpr auto zpp::thread_attr::native_prio ( ) const
inlineconstexprnoexcept

get the Zephyr native priority value

Returns
The native priority value

Definition at line 204 of file thread_attr.hpp.

205  {
206  return m_prio.native_value();
207  }
constexpr int native_value() const noexcept
Get the Zephyr native priority value.
Definition: thread_prio.hpp:49

References zpp::thread_prio::native_value().

◆ operator=() [1/2]

thread_attr& zpp::thread_attr::operator= ( const thread_attr )
defaultnoexcept

◆ operator=() [2/2]

thread_attr& zpp::thread_attr::operator= ( thread_attr &&  )
defaultnoexcept

◆ set() [1/10]

constexpr void zpp::thread_attr::set ( ) const
inlineconstexprnoexcept

Definition at line 65 of file thread_attr.hpp.

66  {
67  }

Referenced by thread_attr(), and set().

◆ set() [2/10]

template<class T_Rep , class T_Period >
constexpr void zpp::thread_attr::set ( const thread_start_delay< T_Rep, T_Period > &  delay)
inlineconstexprnoexcept

Set the thread start delay.

Parameters
delayThe thread start delay

Definition at line 86 of file thread_attr.hpp.

87  {
88  using namespace std::chrono;
89 
90  //auto ms = duration_cast<milliseconds>(delay.t);
91 
92  if (delay.t <= decltype(delay.t)::zero()) {
93  m_delay = K_NO_WAIT;
94  } else {
95  m_delay = to_tick(delay.t);
96  }
97  }
constexpr k_ticks_t to_tick(const std::chrono::duration< T_Rep, T_Period > &d) noexcept
convert a duration to tick
Definition: clock.hpp:72

References zpp::to_tick().

◆ set() [3/10]

template<class T_FirstArg , class ... T_Args>
constexpr void zpp::thread_attr::set ( T_FirstArg &&  first,
T_Args &&...  rest 
)
inlineconstexprnoexcept

Definition at line 59 of file thread_attr.hpp.

60  {
61  set(std::forward<T_FirstArg>(first));
62  set(std::forward<T_Args>(rest)...);
63  }

References set().

Referenced by ZTEST().

◆ set() [4/10]

constexpr void zpp::thread_attr::set ( thread_essential  v)
inlineconstexprnoexcept

Set the thread essential flag.

Parameters
vThe thread essential flag

Definition at line 120 of file thread_attr.hpp.

121  {
122  if (v == thread_essential::yes) {
123  m_options |= K_ESSENTIAL;
124  } else {
125  m_options &= ~K_ESSENTIAL;
126  }
127  }

References zpp::yes.

◆ set() [5/10]

constexpr void zpp::thread_attr::set ( thread_fp_regs  v)
inlineconstexprnoexcept

Set the thread FP regs flag.

Parameters
vThe thread FP regs flag

Definition at line 162 of file thread_attr.hpp.

163  {
164 #ifdef K_FP_REGS
165  if (v == thread_fp_regs::yes) {
166  m_options |= K_FP_REGS;
167  } else {
168  m_options &= ~K_FP_REGS;
169  }
170 #endif
171  }

References zpp::yes.

◆ set() [6/10]

constexpr void zpp::thread_attr::set ( thread_inherit_perms  v)
inlineconstexprnoexcept

Set the thread inherit permisions flag.

Parameters
vThe thread inherit permissions flag

Definition at line 148 of file thread_attr.hpp.

149  {
150  if (v == thread_inherit_perms::yes) {
151  m_options |= K_INHERIT_PERMS;
152  } else {
153  m_options &= ~K_INHERIT_PERMS;
154  }
155  }

References zpp::yes.

◆ set() [7/10]

constexpr void zpp::thread_attr::set ( thread_prio  prio)
inlineconstexprnoexcept

Set the thread priority.

Parameters
prioThe thread priority

Definition at line 74 of file thread_attr.hpp.

75  {
76  m_prio = prio;
77  }

◆ set() [8/10]

constexpr void zpp::thread_attr::set ( thread_sse_regs  v)
inlineconstexprnoexcept

Set the thread SSE regs flag.

Parameters
vThe thread SSE regs flag

Definition at line 178 of file thread_attr.hpp.

179  {
180 #ifdef K_SSE_REGS
181  if (v == thread_sse_regs::yes) {
182  m_options |= K_SSE_REGS;
183  } else {
184  m_options &= ~K_SSE_REGS;
185  }
186 #endif
187  }

References zpp::yes.

◆ set() [9/10]

constexpr void zpp::thread_attr::set ( thread_suspend  v)
inlineconstexprnoexcept

Set the thread start suspended flag.

Parameters
vThe thread start suspended flag

Definition at line 104 of file thread_attr.hpp.

105  {
106  if (v == thread_suspend::yes) {
107  m_delay = K_FOREVER;
108  } else {
109  if (K_TIMEOUT_EQ(m_delay, K_FOREVER)) {
110  m_delay = K_NO_WAIT;
111  }
112  }
113  }

References zpp::yes.

◆ set() [10/10]

constexpr void zpp::thread_attr::set ( thread_user  v)
inlineconstexprnoexcept

Set the thread user flag.

Parameters
vThe thread user flag

Definition at line 134 of file thread_attr.hpp.

135  {
136  if (v == thread_user::yes) {
137  m_options |= K_USER;
138  } else {
139  m_options &= ~K_USER;
140  }
141  }

References zpp::yes.


The documentation for this class was generated from the following file: