From 10cf2f22701bbf5b2e7e69f9980cf6b6133b8a48 Mon Sep 17 00:00:00 2001 From: Patrick Pelissier Date: Sat, 24 Nov 2018 11:37:09 +0100 Subject: [PATCH] Prepare concurent for using different lock strategy --- m-concurrent.h | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/m-concurrent.h b/m-concurrent.h index 50bab27d..e578499d 100644 --- a/m-concurrent.h +++ b/m-concurrent.h @@ -111,7 +111,35 @@ \ typedef type M_C(name, _type_t); \ \ - \ + /* Define the lock strategy (global & shared lock) */ \ + static inline void \ + M_C(name, _read_lock)(concurrent_t out) \ + { \ + m_mutex_lock (out->lock); \ + } \ + \ + static inline void \ + M_C(name, _read_unlock)(concurrent_t out) \ + { \ + m_mutex_unlock (out->lock); \ + } \ + \ + static inline void \ + M_C(name, _write_lock)(concurrent_t out) \ + { \ + m_mutex_lock (out->lock); \ + } \ + \ + static inline void \ + M_C(name, _write_unlock)(concurrent_t out) \ + { \ + m_mutex_unlock (out->lock); \ + } \ + \ + CONCURRENTI_DEF_FUNC(name, type, oplist, concurrent_t, concurrent_it_t) + +// Internal definition of the functions. +#define CONCURRENTI_DEF_FUNC(name, type, oplist, concurrent_t, concurrent_it_t) \ M_IF_METHOD(INIT, oplist)( \ static inline void \ M_C(name, _init)(concurrent_t out) \