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

Double linked list node, with time stamp and thread. More...

#include <os-lists.h>

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

Public Member Functions

Constructors & Destructor
 timeout_thread_node (port::clock::timestamp_t ts, thread &th)
 Construct a clock timeout node.
 
virtual ~timeout_thread_node () override
 Destruct the node.
 
Public Member Functions
virtual void action (void) override
 Action to perform when the time stamp is reached.
 
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
 
void next (static_double_list_links *n)
 
static_double_list_linksprev (void) const
 
void prev (static_double_list_links *n)
 

Public Attributes

Public Member Variables
rtos::threadthread
 Reference to thread who initiated the timeout.
 
Public Member Variables
port::clock::timestamp_t timestamp
 Time stamp when the next action will be performed.
 

Protected Attributes

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

Detailed Description

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

Constructor & Destructor Documentation

◆ timeout_thread_node()

os::rtos::internal::timeout_thread_node::timeout_thread_node ( port::clock::timestamp_t  ts,
rtos::thread th 
)
Parameters
[in]tsTime stamp.
[in]thReference to thread.

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

329 : timestamp_node{ ts }, //
330 thread (th)
331 {
332#if defined(OS_TRACE_RTOS_LISTS_CONSTRUCT)
333 trace::printf ("%s() %p \n", __func__, this);
334#endif
335 }
rtos::thread & thread
Reference to thread who initiated the timeout.
Definition os-lists.h:289
timestamp_node(port::clock::timestamp_t ts)
Construct a node with a time stamp.
Definition os-lists.cpp:311
int printf(const char *format,...)
Write a formatted string to the trace device.
Definition trace.cpp:59

References os::trace::printf().

◆ ~timeout_thread_node()

os::rtos::internal::timeout_thread_node::~timeout_thread_node ( )
overridevirtual

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

338 {
339#if defined(OS_TRACE_RTOS_LISTS_CONSTRUCT)
340 trace::printf ("%s() %p \n", __func__, this);
341#endif
342 }

References os::trace::printf().

Member Function Documentation

◆ action()

void os::rtos::internal::timeout_thread_node::action ( void  )
overridevirtual
Parameters
None.
Returns
Nothing.

Implements os::rtos::internal::timestamp_node.

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

347 {
348 rtos::thread* th = &this->thread;
349 this->unlink ();
350
351 thread::state_t state = th->state ();
352 if (state != thread::state::destroyed)
353 {
354 th->resume ();
355 }
356 }
uint8_t state_t
Type of variables holding thread states.
Definition os-thread.h:357
@ destroyed
Terminated and resources (like stack) released.
Definition os-thread.h:398

References os::rtos::thread::state::destroyed, os::rtos::thread::resume(), os::rtos::thread::state(), thread, and os::utils::static_double_list_links::unlink().

◆ next() [1/2]

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

Definition at line 847 of file lists.h.

848 {
849 next_ = n;
850 }

References os::utils::static_double_list_links::next_.

◆ next() [2/2]

◆ prev() [1/2]

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

Definition at line 853 of file lists.h.

854 {
855 prev_ = n;
856 }

References os::utils::static_double_list_links::prev_.

◆ prev() [2/2]

◆ unlink()

void os::utils::static_double_list_links::unlink ( void  )
inherited
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 }

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

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

◆ unlinked()

bool os::utils::static_double_list_links::unlinked ( void  )
inlineinherited
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 os::utils::static_double_list_links::next_.

Referenced by os::utils::static_double_list_links::unlink().

Member Data Documentation

◆ next_

◆ prev_

◆ thread

rtos::thread& os::rtos::internal::timeout_thread_node::thread

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

Referenced by action().

◆ timestamp

port::clock::timestamp_t os::rtos::internal::timestamp_node::timestamp
inherited

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