CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
trlifo.cxh
1/// @brief LIFO-ordered task resource
2///
3/// @defgroup taskresource_lifo LIFO
4/// @ingroup taskresource
5/// @{
6///
7/// TRLifo provides strictly ordered LIFO (Last In, First Out) serialization of task execution.
8/// Tasks are guaranteed to run in reverse order of registration, with the most recent task
9/// running first (stack ordering).
10///
11/// **Characteristics:**
12/// - Stack (LIFO) ordering
13/// - Most recently registered task runs first
14/// - Only one task runs at a time (serialized)
15/// - Efficient for moderate numbers of waiting tasks
16///
17/// **When to use:**
18/// - Need stack-like processing order
19/// - Recent work should be prioritized over older work
20/// - Implementing cancellation hierarchies
21/// - Depth-first processing patterns
22///
23/// **Example use case:**
24/// Resource cleanup where most recent allocations should be freed first.
25/// @}
26#include "taskresource.cxh"
27#include <cx/thread/mutex.h>
28#include <cx/taskqueue/task/complextask.cxh>
29
30/// @addtogroup taskresource_lifo
31/// @{
32/// Strictly ordered LIFO resource for stack-like task execution.
33class TRLifo extends TaskResource {
34 Mutex _lifomtx;
35 ComplexTask *cur; ///< Currently running task
36 sarray:object:ComplexTask _lifo; ///< Stack of waiting tasks
37
38 /// Create a new LIFO-ordered resource.
39 /// @return New TRLifo instance
40 factory create();
41}
42
43/// @}