1/// @brief FIFO-ordered task resource
3/// @defgroup taskresource_fifo FIFO
4/// @ingroup taskresource
7/// TRFifo provides strictly ordered FIFO (First In, First Out) serialization of task execution.
8/// Tasks are guaranteed to run in exactly the order they registered with the resource.
10/// **Characteristics:**
11/// - Linked list implementation scales efficiently to many waiters
12/// - Strict FIFO ordering guaranteed
13/// - Only one task runs at a time (serialized)
14/// - No possibility for tasks to "cut in line"
17/// - Need guaranteed execution order
18/// - Large number of waiting tasks
19/// - Processing queue-like workloads
20/// - Serializing access to order-dependent resources
22/// **Example use case:**
23/// Serializing writes to a file or database where order matters.
25#include "taskresource.cxh"
26#include <cx/thread/mutex.h>
30/// @addtogroup taskresource_fifo
32/// Linked list node for FIFO queue.
35typedef struct TRFifoNode {
36 TRFifoNode *next; ///< Next node in queue
37 ComplexTask *task; ///< Task waiting in queue
40/// Strictly ordered FIFO resource for serialized task execution.
41class TRFifo extends TaskResource {
43 ComplexTask *cur; ///< Currently running task
44 TRFifoNode *head; ///< Head of wait queue
45 TRFifoNode *tail; ///< Tail of wait queue
47 /// Create a new FIFO-ordered resource.
48 /// @return New TRFifo instance