Pigweed
 
Loading...
Searching...
No Matches
pw::ThreadStack< kStackSizeBytes > Class Template Reference

#include <stack.h>

Public Types

using native = internal::ThreadStackPointer
 

Public Member Functions

constexpr native native_pointer ()
 
constexpr size_t native_size () const
 

Detailed Description

template<size_t kStackSizeBytes>
class pw::ThreadStack< kStackSizeBytes >

Declares a stack to use with a ThreadContext<> without an integrated stack.

Allocating stacks alongside the ThreadContext (e.g. with ThreadContext<1024>) is simpler, but more limited. Declaring a ThreadStack separately gives you more control. For example, you can:

  • Declare thread stacks at specific addresses (e.g. with PW_PLACE_IN_SECTION.)
  • Specify larger-than-native alignments (e.g. alignas(256) pw::ThreadStack<1024>).
  • Poison memory immediately before/after the stack to help detect overflow.

Member Typedef Documentation

◆ native

template<size_t kStackSizeBytes>
using pw::ThreadStack< kStackSizeBytes >::native = internal::ThreadStackPointer

Native stack "element". Operating systems typically accept a pointer to this type in their thread creation APIs. May be void for APIs that take a void*, such as pthread_attr_setstack().

Member Function Documentation

◆ native_pointer()

template<size_t kStackSizeBytes>
constexpr native pw::ThreadStack< kStackSizeBytes >::native_pointer ( )
inlineconstexpr

Returns a pointer to the native stack.

Warning
Calling this function is not portable.

◆ native_size()

template<size_t kStackSizeBytes>
constexpr size_t pw::ThreadStack< kStackSizeBytes >::native_size ( ) const
inlineconstexpr

Returns the size of the stack in terms of the native units – NOT necessarily bytes!

Warning
Calling this function is not portable.

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