Function check_if_mutex_is_blocked

Source
pub fn check_if_mutex_is_blocked(mutex: &Arc<Mutex<i32>>) -> bool
Expand description

Checks if a given mutex is currently locked without blocking.

This function attempts to acquire the mutex immediately. If successful, it means the mutex was not blocked. If unsuccessful, it indicates the mutex is currently held by another thread. This function is used by time-critical control algorithms (e.g., heating or ventilation) to identify root causes for excessive cycle times.

§Arguments

  • mutex - A reference to the Arc<Mutex<i32>> to be checked for its locked status.

§Returns

true if the mutex is currently blocked (locked by another thread); false if the mutex is not blocked and could be acquired immediately.