Commit 40224b51 authored by tqcq's avatar tqcq
Browse files

fix sigslot

parent e1d529e8
Loading
Loading
Loading
Loading
Loading
+14 −13
Original line number Diff line number Diff line
@@ -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(const multi_threaded_local &)
    // {
    //     pthread_mutex_init(&m_mutex, nullptr);
    // }
    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<mt_policy, A1, A2, A3, A4, A5, A6, A7,
}// namespace sigslot

#endif// SLED_SIGSLOT_H
#endif// __SIGSLOT_H__