µ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::double_list Class Reference

Circular double linked list of nodes. More...

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

+ Inheritance diagram for os::utils::double_list:

Public Member Functions

Constructors & Destructor
 double_list ()
 Construct a list.
 
 ~double_list ()
 Destruct the list.
 
Public Member Functions
bool uninitialized (void) const
 Check if the list is uninitialised.
 
void clear (void)
 Clear the list.
 
bool empty (void) const
 Check if the list is empty.
 
volatile static_double_list_linkshead (void) const
 Get the list head.
 
volatile static_double_list_linkstail (void) const
 Get the list tail.
 

Protected Member Functions

Private Member Functions
void insert_after (static_double_list_links &node, static_double_list_links *after)
 Insert a new node after existing node.
 

Protected Attributes

Private Member Variables
static_double_list_links head_
 A list node used to point to head and tail.
 

Detailed Description

Definition at line 487 of file lists.h.

Constructor & Destructor Documentation

◆ double_list()

os::utils::double_list::double_list ( )

The initial list status is empty.

Definition at line 153 of file lists.cpp.

154 {
155#if defined(OS_TRACE_UTILS_LISTS_CONSTRUCT) || defined(OS_TRACE_UTILS_LISTS)
156 trace::printf ("%s() %p \n", __func__, this);
157#endif
158
159 clear ();
160 }
void clear(void)
Clear the list.
Definition lists.cpp:108
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References os::utils::static_double_list::clear(), and os::trace::printf().

◆ ~double_list()

os::utils::double_list::~double_list ( )

There must be no nodes in the list.

Definition at line 166 of file lists.cpp.

167 {
168#if defined(OS_TRACE_UTILS_LISTS_CONSTRUCT) || defined(OS_TRACE_UTILS_LISTS)
169 trace::printf ("%s() %p \n", __func__, this);
170#endif
171
172 assert (empty ());
173 }
bool empty(void) const
Check if the list is empty.
Definition lists.h:1001

References os::utils::static_double_list::empty(), and os::trace::printf().

Member Function Documentation

◆ clear()

void os::utils::static_double_list::clear ( void  )
inherited
Parameters
None.
Returns
Nothing.

Initialise the mandatory node with links to itself.

Definition at line 108 of file lists.cpp.

109 {
110#pragma GCC diagnostic push
111#if defined(__clang__)
112#elif defined(__GNUC__)
113#pragma GCC diagnostic ignored "-Wuseless-cast"
114#endif
115 head_.next (const_cast<static_double_list_links*> (&head_));
116 head_.prev (const_cast<static_double_list_links*> (&head_));
117#pragma GCC diagnostic pop
118 }
static_double_list_links head_
A list node used to point to head and tail.
Definition lists.h:473

References os::utils::static_double_list::head_, os::utils::static_double_list_links::next(), and os::utils::static_double_list_links::prev().

Referenced by double_list(), os::rtos::internal::ready_threads_list::link(), and os::rtos::internal::terminated_threads_list::link().

◆ empty()

bool os::utils::static_double_list::empty ( void  ) const
inlineinherited

◆ head()

volatile static_double_list_links * os::utils::static_double_list::head ( void  ) const
inlineinherited
Parameters
None.
Returns
Pointer to head node.

Definition at line 1008 of file lists.h.

1009 {
1010 return static_cast<volatile static_double_list_links*> (head_.next ());
1011 }

References os::utils::static_double_list::head_, and os::utils::static_double_list_links::next().

◆ insert_after()

void os::utils::static_double_list::insert_after ( static_double_list_links node,
static_double_list_links after 
)
protectedinherited
Parameters
nodeReference to node to insert.
afterReference to existing node.
Returns
Nothing.

Definition at line 121 of file lists.cpp.

123 {
124#if defined(OS_TRACE_UTILS_LISTS)
125 trace::printf ("%s() n=%p after %p\n", __func__, &node, after);
126#endif
127
128 // Unlinked nodes must have both pointers null.
129 // If not, most probably the node was already linked.
130 // Or the memory is corrupted.
131 assert (node.prev () == nullptr);
132 assert (node.next () == nullptr);
133
134 // The `after` node must be linked. Only the `next` pointer is
135 // tested, since only it is used.
136 assert (after->next () != nullptr);
137
138 // Make the new node point to its neighbours.
139 node.prev (after);
140 node.next (after->next ());
141
142 // Make the neighbours point to the node. The order is important.
143 after->next ()->prev (&node);
144 after->next (&node);
145 }

References os::utils::static_double_list_links::next(), os::utils::static_double_list_links::prev(), and os::trace::printf().

Referenced by os::rtos::internal::thread_children_list::link(), os::rtos::internal::clock_timestamps_list::link(), os::rtos::internal::ready_threads_list::link(), os::rtos::internal::waiting_threads_list::link(), and os::rtos::internal::terminated_threads_list::link().

◆ tail()

◆ uninitialized()

bool os::utils::static_double_list::uninitialized ( void  ) const
inlineinherited
Parameters
None.
Return values
trueThe list was not initialised.
falseThe list was initialised.

Definition at line 994 of file lists.h.

995 {
996 // If it points to nowhere, it is not yet initialised.
997 return (head_.prev () == nullptr);
998 }

References os::utils::static_double_list::head_, and os::utils::static_double_list_links::prev().

Member Data Documentation

◆ head_


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