µOS++ IIIe Reference 7.0.0
The third edition of µOS++, a POSIX inspired open source framework, written in C++
Loading...
Searching...
No Matches
os::utils::static_double_list_links Class Reference

Statically allocated core of a double linked list, pointers to next, previous. More...

#include <cmsis-plus/utils/lists.h>

+ Inheritance diagram for os::utils::static_double_list_links:

Public Member Functions

Constructors & Destructor
 static_double_list_links ()
 Construct a list node (BSS initialised).
 
 ~static_double_list_links ()
 Destruct the node.
 
Public Member Functions
void unlink (void)
 Remove the node from the list.
 
bool unlinked (void)
 Check if the node is unlinked.
 
static_double_list_linksnext (void) const
 
static_double_list_linksprev (void) const
 
void next (static_double_list_links *n)
 
void prev (static_double_list_links *n)
 

Protected Attributes

Private Member Variables
static_double_list_linksprev_
 Pointer to previous node.
 
static_double_list_linksnext_
 Pointer to next node.
 

Detailed Description

This is the simplest list node, used as base class for other list nodes and as storage for static_double_list, that must be available for any statically constructed objects while still avoiding the 'static initialisation order fiasco'.

The idea is to design the object in such a way as to benefit from the standard BSS initialisation, in other words take nullptr as starting values.

Definition at line 47 of file lists.h.

Constructor & Destructor Documentation

◆ static_double_list_links()

os::utils::static_double_list_links::static_double_list_links ( )
inline

Definition at line 814 of file lists.h.

815 {
816 }

◆ ~static_double_list_links()

os::utils::static_double_list_links::~static_double_list_links ( )
inline

Definition at line 818 of file lists.h.

819 {
820 // Revert the content to a state similar to the statically initialised
821 // state (BSS zero).
822 // Unfortunately GCC removes this code as part of
823 // _dead store elimination_.
824 // next_ = nullptr;
825 // prev_ = nullptr;
826 }

Member Function Documentation

◆ next() [1/2]

void os::utils::static_double_list_links::next ( static_double_list_links n)
inline

Definition at line 847 of file lists.h.

848 {
849 next_ = n;
850 }

References next_.

◆ next() [2/2]

◆ prev() [1/2]

void os::utils::static_double_list_links::prev ( static_double_list_links n)
inline

Definition at line 853 of file lists.h.

854 {
855 prev_ = n;
856 }

References prev_.

◆ prev() [2/2]

◆ unlink()

void os::utils::static_double_list_links::unlink ( void  )
Returns
Nothing.

Update the neighbours to point to each other, skipping the node.

For more robustness, to prevent unexpected accesses, the links in the removed node are nullified.

Definition at line 59 of file lists.cpp.

60 {
61 // Check if not already unlinked.
62 if (unlinked ())
63 {
64 assert (prev_ == nullptr);
65#if defined(OS_TRACE_UTILS_LISTS)
66 trace::printf ("%s() %p nop\n", __func__, this);
67#endif
68 return;
69 }
70
71#if defined(OS_TRACE_UTILS_LISTS)
72 trace::printf ("%s() %p \n", __func__, this);
73#endif
74
75 // Make neighbours point to each other.
76 prev_->next_ = next_;
77 next_->prev_ = prev_;
78
79 // Nullify both pointers in the unlinked node.
80 prev_ = nullptr;
81 next_ = nullptr;
82 }
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References next_, prev_, os::trace::printf(), and unlinked().

Referenced by os::rtos::internal::timeout_thread_node::action(), os::rtos::internal::timer_node::action(), and os_rtos_idle_actions().

◆ unlinked()

bool os::utils::static_double_list_links::unlinked ( void  )
inline
Return values
trueThe node is not linked.
falseThe node is linked to a list.

Definition at line 829 of file lists.h.

830 {
831 return (next_ == nullptr);
832 }

References next_.

Referenced by unlink().

Member Data Documentation

◆ next_

static_double_list_links* os::utils::static_double_list_links::next_
protected

◆ prev_

static_double_list_links* os::utils::static_double_list_links::prev_
protected

Definition at line 132 of file lists.h.

Referenced by os::utils::double_list_links::double_list_links(), prev(), prev(), and unlink().


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