From 174df99ffa53f1091589eaa4fa0c16cdd55a9326 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= Date: Sat, 21 Oct 2023 04:55:41 +0200 Subject: ALL: use new mp_thread abstraction --- options/m_config_core.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'options/m_config_core.c') diff --git a/options/m_config_core.c b/options/m_config_core.c index 4e488ca01d..08a76eb76d 100644 --- a/options/m_config_core.c +++ b/options/m_config_core.c @@ -17,7 +17,6 @@ #include #include -#include #include #include #include @@ -25,17 +24,18 @@ #include #include -#include "m_config_core.h" -#include "options/m_option.h" #include "common/common.h" #include "common/global.h" -#include "common/msg.h" #include "common/msg_control.h" +#include "common/msg.h" +#include "m_config_core.h" #include "misc/dispatch.h" +#include "options/m_option.h" +#include "osdep/threads.h" // For use with m_config_cache. struct m_config_shadow { - pthread_mutex_t lock; + mp_mutex lock; // Incremented on every option change. _Atomic uint64_t ts; // -- immutable after init @@ -417,14 +417,14 @@ static void shadow_destroy(void *p) assert(shadow->num_listeners == 0); talloc_free(shadow->data); - pthread_mutex_destroy(&shadow->lock); + mp_mutex_destroy(&shadow->lock); } struct m_config_shadow *m_config_shadow_new(const struct m_sub_options *root) { struct m_config_shadow *shadow = talloc_zero(NULL, struct m_config_shadow); talloc_set_destructor(shadow, shadow_destroy); - pthread_mutex_init(&shadow->lock, NULL); + mp_mutex_init(&shadow->lock); add_sub_group(shadow, NULL, -1, -1, root); @@ -566,9 +566,9 @@ struct m_config_cache *m_config_cache_from_shadow(void *ta_parent, in->shadow = shadow; in->src = shadow->data; - pthread_mutex_lock(&shadow->lock); + mp_mutex_lock(&shadow->lock); in->data = allocate_option_data(cache, shadow, group_index, in->src); - pthread_mutex_unlock(&shadow->lock); + mp_mutex_unlock(&shadow->lock); cache->opts = in->data->gdata[0].udata; @@ -675,7 +675,7 @@ bool m_config_cache_update(struct m_config_cache *cache) if (!cache_check_update(cache)) return false; - pthread_mutex_lock(&shadow->lock); + mp_mutex_lock(&shadow->lock); bool res = false; while (1) { void *p; @@ -684,7 +684,7 @@ bool m_config_cache_update(struct m_config_cache *cache) break; res = true; } - pthread_mutex_unlock(&shadow->lock); + mp_mutex_unlock(&shadow->lock); return res; } @@ -697,9 +697,9 @@ bool m_config_cache_get_next_changed(struct m_config_cache *cache, void **opt) if (!cache_check_update(cache) && in->upd_group < 0) return false; - pthread_mutex_lock(&shadow->lock); + mp_mutex_lock(&shadow->lock); update_next_option(cache, opt); - pthread_mutex_unlock(&shadow->lock); + mp_mutex_unlock(&shadow->lock); return !!*opt; } @@ -744,7 +744,7 @@ bool m_config_cache_write_opt(struct m_config_cache *cache, void *ptr) struct m_config_group *g = &shadow->groups[group_idx]; const struct m_option *opt = &g->group->opts[opt_idx]; - pthread_mutex_lock(&shadow->lock); + mp_mutex_lock(&shadow->lock); struct m_group_data *gdst = m_config_gdata(in->data, group_idx); struct m_group_data *gsrc = m_config_gdata(in->src, group_idx); @@ -763,7 +763,7 @@ bool m_config_cache_write_opt(struct m_config_cache *cache, void *ptr) } } - pthread_mutex_unlock(&shadow->lock); + mp_mutex_unlock(&shadow->lock); return changed; } @@ -774,7 +774,7 @@ void m_config_cache_set_wakeup_cb(struct m_config_cache *cache, struct config_cache *in = cache->internal; struct m_config_shadow *shadow = in->shadow; - pthread_mutex_lock(&shadow->lock); + mp_mutex_lock(&shadow->lock); if (in->in_list) { for (int n = 0; n < shadow->num_listeners; n++) { if (shadow->listeners[n] == in) { @@ -796,7 +796,7 @@ void m_config_cache_set_wakeup_cb(struct m_config_cache *cache, in->wakeup_cb = cb; in->wakeup_cb_ctx = cb_ctx; } - pthread_mutex_unlock(&shadow->lock); + mp_mutex_unlock(&shadow->lock); } static void dispatch_notify(void *p) -- cgit v1.2.3