Skip to content

Commit

Permalink
core/mutex: add mutex_init_locked()
Browse files Browse the repository at this point in the history
  • Loading branch information
benpicco committed Nov 6, 2024
1 parent 2734366 commit 8b5eee6
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions core/include/mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,17 @@ static inline void mutex_init(mutex_t *mutex)
mutex->queue.next = NULL;
}

/**
* @brief Initializes a mutex object in a locked state.
* @details For initialization of variables use MUTEX_INIT_LOCKED instead.
* Only use the function call for dynamically allocated mutexes.
* @param[out] mutex pre-allocated mutex structure, must not be NULL.
*/
static inline void mutex_init_locked(mutex_t *mutex)
{
mutex->queue.next = MUTEX_LOCKED;
}

/**
* @brief Initialize a mutex cancellation structure
* @param mutex The mutex that the calling thread wants to lock
Expand Down

0 comments on commit 8b5eee6

Please sign in to comment.