// clang-format off // SPDX-FileCopyrightText: 2023 Klarälvdalens Datakonsult AB, a KDAB Group company // clang-format on // SPDX-FileContributor: Andrew Hayzen // // SPDX-License-Identifier: MIT OR Apache-2.0 #pragma once #include #include #include namespace rust::cxxqt1 { template class CxxQtThreading { public: explicit CxxQtThreading(T* obj) : m_cxxQtThreadObj(::std::make_shared>(obj)) { } virtual ~CxxQtThreading() { const auto guard = ::std::unique_lock(m_cxxQtThreadObj->mutex); m_cxxQtThreadObj->ptr = nullptr; } CxxQtThread qtThread() const { return CxxQtThread(m_cxxQtThreadObj); } private: ::std::shared_ptr> m_cxxQtThreadObj; }; template CxxQtThread qtThread(const T& qobject) { return static_cast&>(qobject).qtThread(); } }