µ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::rtos::internal::terminated_threads_list Class Reference

Unordered list of threads. More...

#include <os-lists.h>

+ Inheritance diagram for os::rtos::internal::terminated_threads_list:

Public Member Functions

Constructors & Destructor
 terminated_threads_list ()
 Construct a list of waiting threads.
 
 ~terminated_threads_list ()
 Destruct the list.
 
Public Member Functions
void link (waiting_thread_node &node)
 Add a new thread node to the list.
 
volatile waiting_thread_nodehead (void) const
 Get list head.
 
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_links * tail (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 747 of file os-lists.h.

Constructor & Destructor Documentation

◆ terminated_threads_list()

os::rtos::internal::terminated_threads_list::terminated_threads_list ( )
inline

The initial list status is empty.

Definition at line 977 of file os-lists.h.

978 {
979 }

◆ ~terminated_threads_list()

os::rtos::internal::terminated_threads_list::~terminated_threads_list ( )
inline

Definition at line 981 of file os-lists.h.

982 {
983 }

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 os::utils::double_list::double_list(), os::rtos::internal::ready_threads_list::link(), and link().

◆ empty()

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

◆ head()

volatile waiting_thread_node * os::rtos::internal::terminated_threads_list::head ( void  ) const
inline
Parameters
None.
Returns
Casted pointer to head node.

Definition at line 986 of file os-lists.h.

987 {
988 return static_cast<volatile waiting_thread_node*> (
989 static_double_list::head ());
990 }

◆ 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 }
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

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 link().

◆ link()

void os::rtos::internal::terminated_threads_list::link ( waiting_thread_node node)
Parameters
[in]nodeReference to a list node.
Returns
Nothing.

Definition at line 535 of file os-lists.cpp.

536 {
537 if (head_.prev () == nullptr)
538 {
539 // If this is the first time, initialise the list to empty.
540 clear ();
541 }
542
543 waiting_thread_node* after = static_cast<waiting_thread_node*> (
544 const_cast<utils::static_double_list_links*> (tail ()));
545
546#if defined(OS_TRACE_RTOS_THREAD)
547 trace::printf ("terminated %s() %p %s\n", __func__, &node.thread_,
548 node.thread_->name ());
549#endif
550
551 node.thread_->state_ = thread::state::terminated;
552
553 insert_after (node, after);
554 }
void insert_after(static_double_list_links &node, static_double_list_links *after)
Insert a new node after existing node.
Definition lists.cpp:121
void clear(void)
Clear the list.
Definition lists.cpp:108
volatile static_double_list_links * tail(void) const
Get the list tail.
Definition lists.h:1014
@ terminated
No longer usable, but resources not yet released.
Definition os-thread.h:394

References os::utils::static_double_list::clear(), os::utils::static_double_list::head_, os::utils::static_double_list::insert_after(), os::rtos::internal::object_named::name(), os::utils::static_double_list_links::prev(), os::trace::printf(), os::utils::static_double_list::tail(), os::rtos::thread::state::terminated, and os::rtos::internal::waiting_thread_node::thread_.

◆ tail()

volatile static_double_list_links * os::utils::static_double_list::tail ( void  ) const
inlineinherited

◆ 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: