From d079b656b4719739b2247dcd9d46e9bec793095a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Mon, 6 Feb 2023 17:11:34 +0100 Subject: Merging upstream version 1.38.0. Signed-off-by: Daniel Baumann --- ml/Mutex.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 ml/Mutex.h (limited to 'ml/Mutex.h') diff --git a/ml/Mutex.h b/ml/Mutex.h new file mode 100644 index 000000000..fcdb75313 --- /dev/null +++ b/ml/Mutex.h @@ -0,0 +1,36 @@ +#ifndef ML_MUTEX_H +#define ML_MUTEX_H + +#include "ml-private.h" + +class Mutex { +public: + Mutex() { + netdata_mutex_init(&M); + } + + void lock() { + netdata_mutex_lock(&M); + } + + void unlock() { + netdata_mutex_unlock(&M); + } + + bool try_lock() { + return netdata_mutex_trylock(&M) == 0; + } + + netdata_mutex_t *inner() { + return &M; + } + + ~Mutex() { + netdata_mutex_destroy(&M); + } + +private: + netdata_mutex_t M; +}; + +#endif /* ML_MUTEX_H */ -- cgit v1.2.3