From 40224b51c342469f0fb4382cfbf1d3a0d24e90f0 Mon Sep 17 00:00:00 2001 From: tqcq <99722391+tqcq@users.noreply.github.com> Date: Fri, 20 Dec 2024 14:23:53 +0800 Subject: [PATCH] fix sigslot --- src/sled/sigslot.h | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/src/sled/sigslot.h b/src/sled/sigslot.h index a4dbe4a..6a01398 100644 --- a/src/sled/sigslot.h +++ b/src/sled/sigslot.h @@ -94,6 +94,8 @@ // If signalx is single threaded the user must ensure that disconnect, connect // or signal is not happening concurrently or data race may occur. +#ifndef __SIGSLOT_H__ +#define __SIGSLOT_H__ #ifndef SLED_SIGSLOT_H #define SLED_SIGSLOT_H #pragma once @@ -203,31 +205,29 @@ private: class multi_threaded_local { public: - // multi_threaded_local() { pthread_mutex_init(&m_mutex, nullptr); } + multi_threaded_local() { pthread_mutex_init(&m_mutex, nullptr); } + // - // multi_threaded_local(const multi_threaded_local &) - // { - // pthread_mutex_init(&m_mutex, nullptr); - // } - // - // ~multi_threaded_local() { pthread_mutex_destroy(&m_mutex); } + multi_threaded_local(const multi_threaded_local &) { pthread_mutex_init(&m_mutex, nullptr); } + + ~multi_threaded_local() { pthread_mutex_destroy(&m_mutex); } void lock() { - mutex_.Lock(); - // pthread_mutex_lock(&m_mutex); + // mutex_.Lock(); + pthread_mutex_lock(&m_mutex); } void unlock() { - mutex_.Unlock(); - // pthread_mutex_unlock(&m_mutex); + // mutex_.Unlock(); + pthread_mutex_unlock(&m_mutex); } private: - sled::RecursiveMutex mutex_; + // sled::RecursiveMutex mutex_; // sled::Mutex mutex_; - // pthread_mutex_t m_mutex; + pthread_mutex_t m_mutex; }; #endif// _SIGSLOT_HAS_POSIX_THREADS @@ -665,3 +665,4 @@ using signal8 = signal_with_thread_policy