1/// @brief Mutex-based task resource
3/// @defgroup taskresource_mutex Mutex
4/// @ingroup taskresource
7/// TRMutex provides mutex-based serialization of task execution. Tasks requiring this resource
8/// will run one at a time, with approximate FIFO ordering.
10/// **Characteristics:**
11/// - Simple hashtable-based wait list
12/// - Approximate FIFO ordering (not strictly guaranteed)
13/// - Good for moderate numbers of waiting tasks
14/// - Can be locked by non-task code (call wakeup() after releasing)
17/// - Moderate contention levels (dozens of tasks)
18/// - Ordering is helpful but not critical
19/// - Simple exclusive access pattern
22/// - Use TRFifo for strict FIFO ordering or large numbers of waiters
23/// - Use TRLifo for stack ordering (most recent first)
25#include "taskresource.cxh"
26#include <cx/thread/mutex.h>
30/// @addtogroup taskresource_mutex
32/// Simple mutex-based resource with approximate FIFO ordering.
33class TRMutex extends TaskResource {
34 Mutex mtx; ///< The actual mutex providing exclusive access
36 /// Manually release a task from wait list.
37 /// Call this after releasing mtx if locked from non-task code.
41 hashtable:object:none _waitlist; ///< Tasks waiting for this resource
43 /// Create a new mutex-based resource.
44 /// @return New TRMutex instance