File indexing completed on 2024-04-28 04:01:22

0001 /* -*- C++ -*-
0002     This file implements debugging aids for multithreaded applications.
0003 
0004     SPDX-FileCopyrightText: 2004-2013 Mirko Boehm <mirko@kde.org>
0005 
0006     SPDX-License-Identifier: LGPL-2.0-or-later
0007 
0008     $Id: DebuggingAids.cpp 20 2005-08-08 21:02:51Z mirko $
0009 */
0010 
0011 #include "debuggingaids.h"
0012 
0013 #include <threadweaver_export.h>
0014 
0015 /** A global mutex for the ThreadWeaver objects.
0016     Generally, you should not use it in your own code. */
0017 THREADWEAVER_EXPORT QMutex ThreadWeaver::GlobalMutex;
0018 THREADWEAVER_EXPORT bool ThreadWeaver::Debug = true;
0019 THREADWEAVER_EXPORT int ThreadWeaver::DebugLevel = 1;
0020 
0021 namespace ThreadWeaver
0022 {
0023 void mutexAssertUnlocked(QMutex *mutex, const char *where)
0024 {
0025     if (mutex->tryLock()) {
0026         mutex->unlock();
0027     } else {
0028         Q_ASSERT_X(false, where, "mutexAssertUnlocked: mutex was locked!");
0029     }
0030 }
0031 
0032 void mutexAssertLocked(QMutex *mutex, const char *where)
0033 {
0034     if (mutex->tryLock()) {
0035         mutex->unlock();
0036         Q_ASSERT_X(false, where, "mutexAssertUnlocked: mutex was locked!");
0037     }
0038 }
0039 
0040 }