1/* -*- C++ -*-
2 This file implements debugging aids for multithreaded applications.
3
4 SPDX-FileCopyrightText: 2004-2013 Mirko Boehm <mirko@kde.org>
5
6 SPDX-License-Identifier: LGPL-2.0-or-later
7
8 $Id: DebuggingAids.cpp 20 2005-08-08 21:02:51Z mirko $
9*/
10
11#include "debuggingaids.h"
12
13#include <threadweaver_export.h>
14
15/** A global mutex for the ThreadWeaver objects.
16 Generally, you should not use it in your own code. */
17THREADWEAVER_EXPORT QMutex ThreadWeaver::GlobalMutex;
18THREADWEAVER_EXPORT bool ThreadWeaver::Debug = true;
19THREADWEAVER_EXPORT int ThreadWeaver::DebugLevel = 1;
20
21namespace ThreadWeaver
22{
23void mutexAssertUnlocked(QMutex *mutex, const char *where)
24{
25 if (mutex->tryLock()) {
26 mutex->unlock();
27 } else {
28 Q_ASSERT_X(false, where, "mutexAssertUnlocked: mutex was locked!");
29 }
30}
31
32void mutexAssertLocked(QMutex *mutex, const char *where)
33{
34 if (mutex->tryLock()) {
35 mutex->unlock();
36 Q_ASSERT_X(false, where, "mutexAssertUnlocked: mutex was locked!");
37 }
38}
39
40}
41

source code of threadweaver/src/debuggingaids.cpp