Skip to content

Commit

Permalink
Make various lock guard deinit explicitly callable so that locks can …
Browse files Browse the repository at this point in the history
…be released manually.
  • Loading branch information
PengZheng committed Jun 7, 2024
1 parent bf0011a commit a014956
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion libs/utils/include/celix_threads.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

#include <pthread.h>
#include <stdbool.h>
#include <stddef.h>

#include "celix_cleanup.h"
#include "celix_errno.h"
Expand Down Expand Up @@ -141,8 +142,8 @@ static CELIX_UNUSED inline celix_mutex_lock_guard_t celixMutexLockGuard_init(cel
static CELIX_UNUSED inline void celixMutexLockGuard_deinit(celix_mutex_lock_guard_t* guard) {
if (guard->mutex) {
celixThreadMutex_unlock(guard->mutex);
guard->mutex = NULL;
}
guard->mutex = NULL;
}

CELIX_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(celix_mutex_lock_guard_t, celixMutexLockGuard_deinit)
Expand Down Expand Up @@ -216,6 +217,7 @@ static CELIX_UNUSED inline celix_rwlock_wlock_guard_t celixRwlockWlockGuard_init
static CELIX_UNUSED inline void celixRwlockWlockGuard_deinit(celix_rwlock_wlock_guard_t* guard) {
if (guard->lock) {
celixThreadRwlock_unlock(guard->lock);
guard->lock = NULL;
}
}

Expand Down Expand Up @@ -263,6 +265,7 @@ static CELIX_UNUSED inline celix_rwlock_rlock_guard_t celixRwlockRlockGuard_init
static CELIX_UNUSED inline void celixRwlockRlockGuard_deinit(celix_rwlock_rlock_guard_t* guard) {
if (guard->lock) {
celixThreadRwlock_unlock(guard->lock);
guard->lock = NULL;
}
}

Expand Down

0 comments on commit a014956

Please sign in to comment.