ThreadWeaver

debuggingaids.cpp
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}
bool tryLock()
void unlock()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:53:19 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.