diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-20 04:49:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2023-07-20 04:49:55 +0000 |
commit | ab1bb5b7f1c3c3a7b240ab7fc8661459ecd7decb (patch) | |
tree | 7a900833aad3ccc685712c6c2a7d87576d54f427 /libnetdata/locks/locks.h | |
parent | Adding upstream version 1.40.1. (diff) | |
download | netdata-upstream/1.41.0.tar.xz netdata-upstream/1.41.0.zip |
Adding upstream version 1.41.0.upstream/1.41.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | libnetdata/locks/locks.h | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/libnetdata/locks/locks.h b/libnetdata/locks/locks.h index 89b110d5e..6b492ae47 100644 --- a/libnetdata/locks/locks.h +++ b/libnetdata/locks/locks.h @@ -20,10 +20,26 @@ typedef struct netdata_spinlock { #define NETDATA_SPINLOCK_INITIALIZER \ { .locked = false } -void netdata_spinlock_init(SPINLOCK *spinlock); -void netdata_spinlock_lock(SPINLOCK *spinlock); -void netdata_spinlock_unlock(SPINLOCK *spinlock); -bool netdata_spinlock_trylock(SPINLOCK *spinlock); +void spinlock_init(SPINLOCK *spinlock); +void spinlock_lock(SPINLOCK *spinlock); +void spinlock_unlock(SPINLOCK *spinlock); +bool spinlock_trylock(SPINLOCK *spinlock); + +typedef struct netdata_rw_spinlock { + int32_t readers; + SPINLOCK spinlock; +} RW_SPINLOCK; + +#define NETDATA_RW_SPINLOCK_INITIALIZER \ + { .readers = 0, .spinlock = NETDATA_SPINLOCK_INITIALIZER } + +void rw_spinlock_init(RW_SPINLOCK *rw_spinlock); +void rw_spinlock_read_lock(RW_SPINLOCK *rw_spinlock); +void rw_spinlock_read_unlock(RW_SPINLOCK *rw_spinlock); +void rw_spinlock_write_lock(RW_SPINLOCK *rw_spinlock); +void rw_spinlock_write_unlock(RW_SPINLOCK *rw_spinlock); +bool rw_spinlock_tryread_lock(RW_SPINLOCK *rw_spinlock); +bool rw_spinlock_trywrite_lock(RW_SPINLOCK *rw_spinlock); #ifdef NETDATA_TRACE_RWLOCKS |