From 57b8826e2cf988d993b46c9c845eade0b76e3157 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20K=C3=B6fferlein?= Date: Sun, 9 Sep 2018 16:46:51 +0200 Subject: [PATCH] pthread support enabled for gsiObject.cc --- src/gsi/gsi/gsiObject.cc | 23 +++++++++++------------ src/gsi/gsi/gsiObject.h | 4 ++-- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/gsi/gsi/gsiObject.cc b/src/gsi/gsi/gsiObject.cc index 0ed9bc3a4..7a277dc15 100644 --- a/src/gsi/gsi/gsiObject.cc +++ b/src/gsi/gsi/gsiObject.cc @@ -26,13 +26,12 @@ #include "gsiDecl.h" #include "tlLog.h" - -#include +#include "tlInternational.h" namespace gsi { -QMutex Proxy::m_lock; +tl::Mutex Proxy::m_lock; Proxy::Proxy (const gsi::ClassBase *_cls_decl) : m_cls_decl (_cls_decl), @@ -50,7 +49,7 @@ Proxy::~Proxy () void *prev_obj = 0; { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); try { prev_obj = set_internal (0, false, false, false); } catch (std::exception &ex) { @@ -73,7 +72,7 @@ Proxy::~Proxy () void Proxy::destroy () { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); if (! m_cls_decl) { m_obj = 0; @@ -108,14 +107,14 @@ Proxy::destroy () void Proxy::detach () { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); detach_internal (); } void Proxy::release () { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); // If the object is managed we first reset the ownership of all other clients // and then make us the owner @@ -134,7 +133,7 @@ Proxy::release () void Proxy::keep () { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); const gsi::ClassBase *cls = m_cls_decl; if (cls) { @@ -157,7 +156,7 @@ Proxy::set (void *obj, bool owned, bool const_ref, bool can_destroy) void *prev_obj; { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); prev_obj = set_internal (obj, owned, const_ref, can_destroy); } @@ -171,7 +170,7 @@ Proxy::set (void *obj, bool owned, bool const_ref, bool can_destroy) void * Proxy::obj () { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); return obj_internal (); } @@ -180,7 +179,7 @@ Proxy::obj_internal () { if (! m_obj) { if (m_destroyed) { - throw tl::Exception (tl::to_string (QObject::tr ("Object has been destroyed already"))); + throw tl::Exception (tl::to_string (tr ("Object has been destroyed already"))); } else { // delayed creation of a detached C++ object .. tl_assert (set_internal (m_cls_decl->create (), true, false, true) == 0); @@ -194,7 +193,7 @@ void Proxy::object_status_changed (gsi::ObjectBase::StatusEventType type) { if (type == gsi::ObjectBase::ObjectDestroyed) { - QMutexLocker locker (&m_lock); + tl::MutexLocker locker (&m_lock); m_destroyed = true; // NOTE: must be set before detach and indicates that the object was destroyed externally. detach_internal (); } else if (type == gsi::ObjectBase::ObjectKeep) { diff --git a/src/gsi/gsi/gsiObject.h b/src/gsi/gsi/gsiObject.h index 223c9f8d2..bdde6d7d7 100644 --- a/src/gsi/gsi/gsiObject.h +++ b/src/gsi/gsi/gsiObject.h @@ -26,10 +26,10 @@ #include "tlObject.h" #include "tlEvents.h" +#include "tlThreads.h" #include "gsiCommon.h" #include -#include // For a comprehensive documentation see gsi.h @@ -240,7 +240,7 @@ private: bool m_const_ref : 1; bool m_destroyed : 1; bool m_can_destroy : 1; - static QMutex m_lock; + static tl::Mutex m_lock; void *set_internal (void *obj, bool owned, bool const_ref, bool can_destroy); void object_status_changed (gsi::ObjectBase::StatusEventType type);