summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--qtools/CMakeLists.txt8
-rw-r--r--qtools/qmutex.cpp95
-rw-r--r--qtools/qmutex.h83
-rw-r--r--qtools/qmutex_p.h90
-rw-r--r--qtools/qmutex_unix.cpp117
-rw-r--r--qtools/qmutex_win32.cpp108
-rw-r--r--qtools/qtextcodec.cpp2
-rw-r--r--qtools/qthread.cpp86
-rw-r--r--qtools/qthread.h77
-rw-r--r--qtools/qthread_p.h85
-rw-r--r--qtools/qthread_unix.cpp239
-rw-r--r--qtools/qthread_win32.cpp158
-rw-r--r--qtools/qtools.pro.in19
-rw-r--r--qtools/qwaitcondition.h68
-rw-r--r--qtools/qwaitcondition_unix.cpp134
-rw-r--r--qtools/qwaitcondition_win32.cpp186
-rw-r--r--src/configimpl.l6
-rw-r--r--src/dot.cpp70
-rw-r--r--src/dot.h10
-rw-r--r--src/dotgraph.cpp12
-rw-r--r--src/dotlegendgraph.cpp2
-rw-r--r--src/dotrunner.cpp83
-rw-r--r--src/dotrunner.h96
-rw-r--r--src/tclscanner.l1
24 files changed, 128 insertions, 1707 deletions
diff --git a/qtools/CMakeLists.txt b/qtools/CMakeLists.txt
index cc64de1..a7082c7 100644
--- a/qtools/CMakeLists.txt
+++ b/qtools/CMakeLists.txt
@@ -25,8 +25,6 @@ qstringlist.cpp
qcstringlist.cpp
qxml.cpp
qmap.cpp
-qthread.cpp
-qmutex.cpp
qutfcodec.cpp
)
@@ -35,9 +33,6 @@ list(APPEND qtools_src
qfile_unix.cpp
qdir_unix.cpp
qfileinfo_unix.cpp
-qthread_unix.cpp
-qmutex_unix.cpp
-qwaitcondition_unix.cpp
)
endif()
@@ -46,9 +41,6 @@ list(APPEND qtools_src
qfile_win32.cpp
qdir_win32.cpp
qfileinfo_win32.cpp
-qthread_win32.cpp
-qmutex_win32.cpp
-qwaitcondition_win32.cpp
)
endif()
diff --git a/qtools/qmutex.cpp b/qtools/qmutex.cpp
deleted file mode 100644
index 08a13bc..0000000
--- a/qtools/qmutex.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <stdio.h>
-
-#include "qglobal.h"
-
-#include "qmutex.h"
-#include "qmutex_p.h"
-
-QMutex::QMutex() : d(new QMutexPrivate())
-{
-}
-
-QMutex::~QMutex()
-{
- delete d;
-}
-
-void QMutex::lock()
-{
- //printf("%p: QMutex::lock(): enter\n",this);
- bool isLocked;
- isLocked = d->contenders.testAndSet(0, 1);
- if (!isLocked)
- {
- isLocked = d->contenders.fetchAndAdd(1)==0;
- if (!isLocked)
- {
- // didn't get the lock, wait for it
- //printf("%p: QMutex::lock(): wait() %d\n",this,(int)d->contenders);
- d->wait();
-
- // release lock
- d->contenders.fetchAndAdd(-1);
- }
- }
- //printf("%p: QMutex::lock(): leave\n",this);
-}
-
-bool QMutex::tryLock()
-{
- bool isLocked = d->contenders.testAndSet(0, 1);
- return isLocked;
-}
-
-void QMutex::unlock()
-{
- //printf("%p: QMutex::unlock(): enter %d\n",this,(int)d->contenders);
- if (!d->contenders.testAndSet(1, 0))
- {
- //printf("%p: QMutex::unlock(): wakeUp()\n",this);
- d->wakeUp();
- }
- //printf("%p: QMutex::unlock(): leave\n",this);
-}
-
diff --git a/qtools/qmutex.h b/qtools/qmutex.h
deleted file mode 100644
index d3d2ac0..0000000
--- a/qtools/qmutex.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMUTEX_H
-#define QMUTEX_H
-
-#include "qglobal.h"
-
-class QMutexPrivate;
-
-class QMutex
-{
-public:
- QMutex();
- ~QMutex();
-
- void lock();
- bool tryLock();
- void unlock();
-
-private:
- QMutex(const QMutex &);
- QMutex &operator=(const QMutex &);
-
- QMutexPrivate *d;
-};
-
-class QMutexLocker
-{
- public:
- QMutexLocker(QMutex *m) : m_mutex(m)
- {
- m_mutex->lock();
- }
- ~QMutexLocker()
- {
- m_mutex->unlock();
- }
- QMutex *mutex() const { return m_mutex; }
-
- private:
- QMutex *m_mutex;
-};
-
-#endif // QMUTEX_H
diff --git a/qtools/qmutex_p.h b/qtools/qmutex_p.h
deleted file mode 100644
index a47b407..0000000
--- a/qtools/qmutex_p.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QMUTEX_P_H
-#define QMUTEX_P_H
-
-#include "qglobal.h"
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
-#include <pthread.h>
-#elif defined(_OS_WIN32_)
-#include <windows.h>
-#endif
-
-class QAtomicInt
-{
- public:
- QAtomicInt(int v=0) : m_value(v) {}
- bool testAndSet(int expectedValue,int newValue);
- int fetchAndAdd(int valueToAdd);
- operator int () const { return m_value; }
- bool operator==(int value) const { return m_value == value; }
- bool operator!=(int value) const { return m_value != value; }
- bool operator!() const { return m_value == 0; }
-
- private:
- volatile int m_value;
-};
-
-class QMutexPrivate
-{
-public:
- QMutexPrivate();
- ~QMutexPrivate();
-
- void wait();
- void wakeUp();
-
- QAtomicInt contenders;
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
- volatile bool wakeup;
- pthread_mutex_t mutex;
- pthread_cond_t cond;
-#elif defined(_OS_WIN32_)
- HANDLE event;
-#else
-#error "unsupported platform"
-#endif
-};
-
-#endif // QMUTEX_P_H
diff --git a/qtools/qmutex_unix.cpp b/qtools/qmutex_unix.cpp
deleted file mode 100644
index 4fe9a58..0000000
--- a/qtools/qmutex_unix.cpp
+++ /dev/null
@@ -1,117 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <errno.h>
-#include <pthread.h>
-
-#include "qglobal.h"
-#include "qmutex.h"
-#include "qmutex_p.h"
-
-static pthread_mutex_t qAtomicMutex = PTHREAD_MUTEX_INITIALIZER;
-
-static void report_error(int code, const char *where, const char *what)
-{
- if (code != 0)
- qWarning("%s: %s failure: %d", where, what, code);
-}
-
-
-QMutexPrivate::QMutexPrivate()
- : contenders(0), wakeup(FALSE)
-{
- report_error(pthread_mutex_init(&mutex, NULL), "QMutex", "mutex init");
- report_error(pthread_cond_init(&cond, NULL), "QMutex", "cv init");
-}
-
-QMutexPrivate::~QMutexPrivate()
-{
- report_error(pthread_cond_destroy(&cond), "QMutex", "cv destroy");
- report_error(pthread_mutex_destroy(&mutex), "QMutex", "mutex destroy");
-}
-
-void QMutexPrivate::wait()
-{
- report_error(pthread_mutex_lock(&mutex), "QMutex::lock", "mutex lock");
- int errorCode = 0;
- while (!wakeup)
- {
- errorCode = pthread_cond_wait(&cond, &mutex);
- if (errorCode)
- {
- report_error(errorCode, "QMutex::lock()", "cv wait");
- }
- }
- wakeup = FALSE;
- report_error(pthread_mutex_unlock(&mutex), "QMutex::lock", "mutex unlock");
-}
-
-void QMutexPrivate::wakeUp()
-{
- report_error(pthread_mutex_lock(&mutex), "QMutex::unlock", "mutex lock");
- wakeup = TRUE;
- report_error(pthread_cond_signal(&cond), "QMutex::unlock", "cv signal");
- report_error(pthread_mutex_unlock(&mutex), "QMutex::unlock", "mutex unlock");
-}
-
-bool QAtomicInt::testAndSet(int expectedValue,int newValue)
-{
- bool returnValue = false;
- pthread_mutex_lock(&qAtomicMutex);
- if (m_value == expectedValue)
- {
- m_value = newValue;
- returnValue = true;
- }
- pthread_mutex_unlock(&qAtomicMutex);
- return returnValue;
-}
-
-int QAtomicInt::fetchAndAdd(int valueToAdd)
-{
- int returnValue;
- pthread_mutex_lock(&qAtomicMutex);
- returnValue = m_value;
- m_value += valueToAdd;
- pthread_mutex_unlock(&qAtomicMutex);
- return returnValue;
-}
-
diff --git a/qtools/qmutex_win32.cpp b/qtools/qmutex_win32.cpp
deleted file mode 100644
index 2d662ea..0000000
--- a/qtools/qmutex_win32.cpp
+++ /dev/null
@@ -1,108 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <windows.h>
-
-#include "qmutex.h"
-#include "qmutex_p.h"
-
-QMutexPrivate::QMutexPrivate()
- : contenders(0)
-{
- event = CreateEvent(0, FALSE, FALSE, 0);
- if (!event)
- qWarning("QMutexPrivate::QMutexPrivate: Cannot create event");
-}
-
-QMutexPrivate::~QMutexPrivate()
-{
- CloseHandle(event);
-}
-
-void QMutexPrivate::wait()
-{
- WaitForSingleObject(event, INFINITE);
-}
-
-void QMutexPrivate::wakeUp()
-{
- SetEvent(event);
-}
-
-//----------------------------------------------------------------------
-
-class QCriticalSection
-{
- public:
- QCriticalSection() { InitializeCriticalSection(&section); }
- ~QCriticalSection() { DeleteCriticalSection(&section); }
- void lock() { EnterCriticalSection(&section); }
- void unlock() { LeaveCriticalSection(&section); }
-
- private:
- CRITICAL_SECTION section;
-};
-
-static QCriticalSection qAtomicCriticalSection;
-
-bool QAtomicInt::testAndSet(int expectedValue,int newValue)
-{
- bool returnValue = false;
- qAtomicCriticalSection.lock();
- if (m_value == expectedValue)
- {
- m_value = newValue;
- returnValue = true;
- }
- qAtomicCriticalSection.unlock();
- return returnValue;
-}
-
-int QAtomicInt::fetchAndAdd(int valueToAdd)
-{
- int returnValue;
- qAtomicCriticalSection.lock();
- returnValue = m_value;
- m_value += valueToAdd;
- qAtomicCriticalSection.unlock();
- return returnValue;
-}
-
diff --git a/qtools/qtextcodec.cpp b/qtools/qtextcodec.cpp
index 8ce266d..13c3d51 100644
--- a/qtools/qtextcodec.cpp
+++ b/qtools/qtextcodec.cpp
@@ -1,5 +1,5 @@
/****************************************************************************
-**
+**
**
** Implementation of QTextCodec class
**
diff --git a/qtools/qthread.cpp b/qtools/qthread.cpp
deleted file mode 100644
index 02c99f2..0000000
--- a/qtools/qthread.cpp
+++ /dev/null
@@ -1,86 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qthread.h"
-#include "qthread_p.h"
-
-QThread::QThread()
- : d(new QThreadPrivate)
-{
-}
-
-QThread::~QThread()
-{
- QMutexLocker locker(&d->mutex);
- if (d->running && !d->finished)
- qWarning("QThread: Destroyed while thread is still running");
- delete d;
-}
-
-bool QThread::isFinished() const
-{
- QMutexLocker locker(&d->mutex);
- return d->finished;
-}
-
-bool QThread::isRunning() const
-{
- QMutexLocker locker(&d->mutex);
- return d->running;
-}
-
-void QThread::setStackSize(unsigned int stackSize)
-{
- QMutexLocker locker(&d->mutex);
- if (d->running)
- {
- qWarning("QThread: Cannot change stack size while thread is running!");
- return;
- }
- d->stackSize = stackSize;
-}
-
-unsigned int QThread::stackSize() const
-{
- QMutexLocker locker(&d->mutex);
- return d->stackSize;
-}
-
diff --git a/qtools/qthread.h b/qtools/qthread.h
deleted file mode 100644
index 81868bd..0000000
--- a/qtools/qthread.h
+++ /dev/null
@@ -1,77 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTHREAD_H
-#define QTHREAD_H
-
-class QThreadPrivate;
-
-class QThread
-{
- public:
- explicit QThread();
- virtual ~QThread();
-
- bool isFinished() const;
- bool isRunning() const;
-
- void start();
- void terminate();
- void wait();
- void setStackSize(unsigned int stackSize);
- unsigned int stackSize() const;
- static int idealThreadCount();
-
-protected:
- // events
- virtual void started() {}
- virtual void finished() {}
- virtual void terminated() {}
-
- // main loop
- virtual void run() {}
-
-private:
- QThreadPrivate *d;
- friend class QThreadPrivate;
-};
-
-#endif // QTHREAD_H
diff --git a/qtools/qthread_p.h b/qtools/qthread_p.h
deleted file mode 100644
index 87692aa..0000000
--- a/qtools/qthread_p.h
+++ /dev/null
@@ -1,85 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QTHREAD_P_H
-#define QTHREAD_P_H
-
-#include "qglobal.h"
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
-#include <pthread.h>
-#elif defined(_OS_WIN32_)
-#include <windows.h>
-#endif
-
-#include "qthread.h"
-#include "qmutex.h"
-#include "qwaitcondition.h"
-
-class QThreadPrivate
-{
-public:
- QThreadPrivate();
- ~QThreadPrivate();
-
- mutable QMutex mutex;
-
- bool running;
- bool finished;
- bool terminated;
- uint stackSize;
-
-#if defined(_OS_UNIX_) || defined(_OS_MAC_)
- pthread_t thread_id;
- QWaitCondition thread_done;
- static void *start(void *arg);
- static void finish(void *arg);
-#elif defined(_OS_WIN32_)
- HANDLE handle;
- static unsigned int __stdcall start(void *);
- static void finish(void *,bool lockAnyway=TRUE);
- int waiters;
-#else
-#error "unsupported platform!"
-#endif
-};
-
-#endif // QTHREAD_P_H
diff --git a/qtools/qthread_unix.cpp b/qtools/qthread_unix.cpp
deleted file mode 100644
index 5871605..0000000
--- a/qtools/qthread_unix.cpp
+++ /dev/null
@@ -1,239 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qglobal.h"
-
-#if defined(_OS_HPUX_)
-#include <sys/pstat.h>
-#elif defined(_OS_MAC_)
-#undef DEBUG
-#include <CoreServices/CoreServices.h>
-#elif defined(_OS_BSDI_)
-#include <mach/mach_types.h>
-#include <sys/systm.h>
-#include <sys/types.h>
-#include <sys/sysctl.h>
-#endif
-#include <signal.h>
-#include <unistd.h>
-#include <stdio.h>
-
-#include "qthread.h"
-#include "qthread_p.h"
-
-
-/**************************************************************************
- ** QThreadPrivate
- *************************************************************************/
-
-QThreadPrivate::QThreadPrivate() :
- running(FALSE), finished(FALSE), terminated(FALSE), stackSize(0)
-{
- thread_id = 0;
-}
-
-QThreadPrivate::~QThreadPrivate()
-{
-}
-
-void *QThreadPrivate::start(void *arg)
-{
-#ifndef __ANDROID__
- pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);
-#endif
- pthread_cleanup_push(QThreadPrivate::finish, arg);
-
- QThread *thr = reinterpret_cast<QThread *>(arg);
-
- thr->started();
-#ifndef __ANDROID__
- pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- pthread_testcancel();
-#endif
- thr->run();
-
- pthread_cleanup_pop(1);
- return 0;
-}
-
-void QThreadPrivate::finish(void *arg)
-{
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadPrivate *d = thr->d;
- QMutexLocker locker(&d->mutex);
-
- d->running = FALSE;
- d->finished = TRUE;
- if (d->terminated)
- thr->terminated();
- d->terminated = FALSE;
- thr->finished();
-
- d->thread_id = 0;
- d->thread_done.wakeAll();
-}
-
-
-
-
-/**************************************************************************
- ** QThread
- *************************************************************************/
-
-void QThread::start()
-{
- QMutexLocker locker(&d->mutex);
- if (d->running) return;
-
- // Block the SIGINT signal. The threads will inherit the signal mask.
- // This will avoid them catching SIGINT instead of this thread.
- sigset_t sigset, oldset;
- sigemptyset(&sigset);
- sigaddset(&sigset, SIGINT);
- pthread_sigmask(SIG_BLOCK, &sigset, &oldset);
-
- d->running = TRUE;
- d->finished = FALSE;
-
- pthread_attr_t attr;
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr,PTHREAD_CREATE_DETACHED);
-#ifndef __ANDROID__
- pthread_attr_setinheritsched(&attr, PTHREAD_INHERIT_SCHED);
-#endif
- if (d->stackSize>0)
- {
-#if defined(_POSIX_THREAD_ATTR_STACKSIZE) && (_POSIX_THREAD_ATTR_STACKSIZE-0>0)
- pthread_attr_setstacksize(&attr,d->stackSize);
-#endif
- }
- int code = pthread_create(&d->thread_id, &attr, QThreadPrivate::start, this);
- pthread_attr_destroy(&attr);
-
- if (code)
- {
- qWarning("QThread::start: Thread creation error: %d", code);
-
- d->running = FALSE;
- d->finished = FALSE;
- d->thread_id = 0;
- }
- else
- {
- // Restore the old signal mask only for this thread.
- pthread_sigmask(SIG_SETMASK, &oldset, NULL);
- }
-}
-
-void QThread::terminate()
-{
- QMutexLocker locker(&d->mutex);
-#ifndef __ANDROID__
- if (!d->thread_id) return;
-
- int code = pthread_cancel(d->thread_id);
- if (code)
- {
- qWarning("QThread::start: Thread termination error: %d", code);
- }
- else
- {
- d->terminated = TRUE;
- }
-#endif
-}
-
-void QThread::wait()
-{
- QMutexLocker locker(&d->mutex);
- if (d->finished || !d->running) return;
-
- while (d->running)
- {
- d->thread_done.wait(locker.mutex());
- }
-}
-
-#if defined(QT_LINUXBASE) && !defined(_SC_NPROCESSORS_ONLN)
-// LSB doesn't define _SC_NPROCESSORS_ONLN.
-# define _SC_NPROCESSORS_ONLN 84
-#endif
-
-int QThread::idealThreadCount()
-{
- int cores = -1;
-#if defined(_OS_MAC_)
- // Mac OS X
- cores = (int)MPProcessorsScheduled();
-#elif defined(_OS_HPUX_)
- // HP-UX
- struct pst_dynamic psd;
- if (pstat_getdynamic(&psd, sizeof(psd), 1, 0) == -1)
- {
- perror("pstat_getdynamic");
- cores = -1;
- }
- else
- {
- cores = (int)psd.psd_proc_cnt;
- }
-#elif defined(_OS_BSDI_)
- // FreeBSD, OpenBSD, NetBSD, BSD/OS
- size_t len = sizeof(cores);
- int mib[2];
- mib[0] = CTL_HW;
- mib[1] = HW_NCPU;
-
- if (sysctl(mib, 2, &cores, &len, NULL, 0) != 0)
- {
- perror("sysctl");
- cores = -1;
- }
-#elif defined(_OS_IRIX_)
- // IRIX
- cores = (int)sysconf(_SC_NPROC_ONLN);
-#else
- // the rest: Linux, Solaris, AIX, Tru64
- cores = (int)sysconf(_SC_NPROCESSORS_ONLN);
-#endif
- return cores;
-}
-
diff --git a/qtools/qthread_win32.cpp b/qtools/qthread_win32.cpp
deleted file mode 100644
index 2c62e93..0000000
--- a/qtools/qthread_win32.cpp
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qthread.h"
-#include "qthread_p.h"
-
-/**************************************************************************
- ** QThreadPrivate
- *************************************************************************/
-
-QThreadPrivate::QThreadPrivate() :
- running(FALSE), finished(FALSE), terminated(FALSE), stackSize(0)
-{
- handle = NULL;
- waiters = 0;
-}
-
-QThreadPrivate::~QThreadPrivate()
-{
-}
-
-unsigned int __stdcall QThreadPrivate::start(void *arg)
-{
- QThread *thr = reinterpret_cast<QThread *>(arg);
- thr->started();
- thr->run();
- finish(arg);
- return 0;
-}
-
-void QThreadPrivate::finish(void *arg,bool lockAnyway)
-{
- QThread *thr = reinterpret_cast<QThread *>(arg);
- QThreadPrivate *d = thr->d;
-
- if (lockAnyway) d->mutex.lock();
-
- d->running = FALSE;
- d->finished = TRUE;
- if (d->terminated) thr->terminated();
- d->terminated = FALSE;
- thr->finished();
-
- if (!d->waiters)
- {
- CloseHandle(d->handle);
- d->handle = 0;
- }
-
- if (lockAnyway) d->mutex.unlock();
-}
-
-/**************************************************************************
- ** QThread
- *************************************************************************/
-
-void QThread::start()
-{
- QMutexLocker locker(&d->mutex);
-
- if (d->running) return;
-
- d->running = TRUE;
- d->finished = FALSE;
- d->terminated = FALSE;
-
- d->handle = CreateThread(NULL,d->stackSize,
- (LPTHREAD_START_ROUTINE)QThreadPrivate::start,this,0,NULL);
-
- if (!d->handle)
- {
- qWarning("QThread::start: Failed to create thread: errno=%d",errno);
- d->running = FALSE;
- d->finished = TRUE;
- return;
- }
-}
-
-void QThread::terminate()
-{
- QMutexLocker locker(&d->mutex);
- if (!d->running) return;
- TerminateThread(d->handle, 0);
- d->terminated = TRUE;
- QThreadPrivate::finish(this);
-}
-
-void QThread::wait()
-{
- QMutexLocker locker(&d->mutex);
- if (d->finished || !d->running) return;
-
- ++d->waiters;
- locker.mutex()->unlock();
-
- WaitForSingleObject(d->handle,INFINITE);
-
- locker.mutex()->lock();
- --d->waiters;
- if (!d->finished) // thread was terminated by someone else
- {
- d->terminated = TRUE;
- QThreadPrivate::finish(this);
- }
-
- if (d->finished && d->waiters)
- {
- CloseHandle(d->handle);
- d->handle = 0;
- }
-}
-
-int QThread::idealThreadCount()
-{
- SYSTEM_INFO sysinfo;
- GetSystemInfo(&sysinfo);
- return sysinfo.dwNumberOfProcessors;
-}
-
-
diff --git a/qtools/qtools.pro.in b/qtools/qtools.pro.in
index ba8a086..21d26cc 100644
--- a/qtools/qtools.pro.in
+++ b/qtools/qtools.pro.in
@@ -44,12 +44,7 @@ HEADERS = qarray.h \
qvaluestack.h \
qmap.h \
qmodules.h \
- qthread.h \
- qthread_p.h \
- qmutex.h \
- qmutex_p.h \
- qutfcodec.h \
- qwaitcondition.h
+ qutfcodec.h
SOURCES = qbuffer.cpp \
qcollection.cpp \
@@ -74,23 +69,15 @@ SOURCES = qbuffer.cpp \
qstringlist.cpp \
qxml.cpp \
qmap.cpp \
- qthread.cpp \
- qmutex.cpp \
qutfcodec.cpp
unix:SOURCES += qfile_unix.cpp \
qdir_unix.cpp \
- qfileinfo_unix.cpp \
- qthread_unix.cpp \
- qmutex_unix.cpp \
- qwaitcondition_unix.cpp
+ qfileinfo_unix.cpp
win32:SOURCES += qfile_win32.cpp \
qdir_win32.cpp \
- qfileinfo_win32.cpp \
- qthread_win32.cpp \
- qmutex_win32.cpp \
- qwaitcondition_win32.cpp
+ qfileinfo_win32.cpp
INCLUDEPATH = .
#TMAKE_CXXFLAGS += -DQT_NO_CODECS -DQT_LITE_UNICODE
diff --git a/qtools/qwaitcondition.h b/qtools/qwaitcondition.h
deleted file mode 100644
index 4d5b3bd..0000000
--- a/qtools/qwaitcondition.h
+++ /dev/null
@@ -1,68 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QWAITCONDITION_H
-#define QWAITCONDITION_H
-
-#include "qglobal.h"
-
-class QWaitConditionPrivate;
-class QMutex;
-
-class QWaitCondition
-{
-public:
- QWaitCondition();
- ~QWaitCondition();
-
- void wait(QMutex *mutex);
-
- void wakeOne();
- void wakeAll();
-
-private:
- QWaitCondition(const QWaitCondition &);
- QWaitCondition &operator=(const QWaitCondition &);
-
- QWaitConditionPrivate * d;
-};
-
-#endif // QWAITCONDITION_H
diff --git a/qtools/qwaitcondition_unix.cpp b/qtools/qwaitcondition_unix.cpp
deleted file mode 100644
index 0a6a09b..0000000
--- a/qtools/qwaitcondition_unix.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "qwaitcondition.h"
-#include "qmutex.h"
-#include <pthread.h>
-
-#define MIN(a,b) ((a)<(b)?(a):(b))
-
-static void report_error(int code, const char *where, const char *what)
-{
- if (code != 0)
- qWarning("%s: %s failure: %d", where, what, code);
-}
-
-class QWaitConditionPrivate
-{
- public:
- pthread_mutex_t mutex;
- pthread_cond_t cond;
- int waiters;
- int wakeups;
-
- void wait()
- {
- int code;
- for (;;)
- {
- code = pthread_cond_wait(&cond, &mutex);
- if (code == 0 && wakeups == 0)
- {
- // many vendors warn of spurious wakeups from
- // pthread_cond_wait(), especially after signal delivery,
- // even though POSIX doesn't allow for it... sigh
- continue;
- }
- break;
- }
-
- --waiters;
- if (code == 0)
- {
- --wakeups;
- }
- else
- {
- report_error(code, "QWaitCondition::wait()", "cv wait");
- }
- report_error(pthread_mutex_unlock(&mutex), "QWaitCondition::wait()", "mutex unlock");
- }
-};
-
-
-QWaitCondition::QWaitCondition()
-{
- d = new QWaitConditionPrivate;
- report_error(pthread_mutex_init(&d->mutex, NULL), "QWaitCondition", "mutex init");
- report_error(pthread_cond_init(&d->cond, NULL), "QWaitCondition", "cv init");
- d->waiters = d->wakeups = 0;
-}
-
-
-QWaitCondition::~QWaitCondition()
-{
- report_error(pthread_cond_destroy(&d->cond), "QWaitCondition", "cv destroy");
- report_error(pthread_mutex_destroy(&d->mutex), "QWaitCondition", "mutex destroy");
- delete d;
-}
-
-void QWaitCondition::wakeOne()
-{
- report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeOne()", "mutex lock");
- d->wakeups = MIN(d->wakeups + 1, d->waiters);
- report_error(pthread_cond_signal(&d->cond), "QWaitCondition::wakeOne()", "cv signal");
- report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeOne()", "mutex unlock");
-}
-
-void QWaitCondition::wakeAll()
-{
- report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wakeAll()", "mutex lock");
- d->wakeups = d->waiters;
- report_error(pthread_cond_broadcast(&d->cond), "QWaitCondition::wakeAll()", "cv broadcast");
- report_error(pthread_mutex_unlock(&d->mutex), "QWaitCondition::wakeAll()", "mutex unlock");
-}
-
-void QWaitCondition::wait(QMutex *mutex)
-{
- if (!mutex) return;
-
- report_error(pthread_mutex_lock(&d->mutex), "QWaitCondition::wait()", "mutex lock");
- ++d->waiters;
- mutex->unlock();
- d->wait();
- mutex->lock();
-}
-
diff --git a/qtools/qwaitcondition_win32.cpp b/qtools/qwaitcondition_win32.cpp
deleted file mode 100644
index 80b7b67..0000000
--- a/qtools/qwaitcondition_win32.cpp
+++ /dev/null
@@ -1,186 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
-** Contact: Nokia Corporation (qt-info@nokia.com)
-**
-** This file is part of the QtCore module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL$
-** No Commercial Usage
-** This file contains pre-release code and may not be distributed.
-** You may use this file in accordance with the terms and conditions
-** contained in the either Technology Preview License Agreement or the
-** Beta Release License Agreement.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 as published by the Free Software
-** Foundation and appearing in the file LICENSE.LGPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU Lesser General Public License version 2.1 requirements
-** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** In addition, as a special exception, Nokia gives you certain
-** additional rights. These rights are described in the Nokia Qt LGPL
-** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
-** package.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3.0 as published by the Free Software
-** Foundation and appearing in the file LICENSE.GPL included in the
-** packaging of this file. Please review the following information to
-** ensure the GNU General Public License version 3.0 requirements will be
-** met: http://www.gnu.org/copyleft/gpl.html.
-**
-** If you are unsure which license is appropriate for your use, please
-** contact the sales department at http://www.qtsoftware.com/contact.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <windows.h>
-#include "qwaitcondition.h"
-#include "qmutex.h"
-#include "qinternallist.h"
-
-//***********************************************************************
-// QWaitConditionPrivate
-// **********************************************************************
-
-class QWaitConditionEvent
-{
-public:
- QWaitConditionEvent() : priority(0), wokenUp(false)
- {
- event = CreateEvent(NULL, TRUE, FALSE, NULL);
- }
- ~QWaitConditionEvent() { CloseHandle(event); }
- int priority;
- bool wokenUp;
- HANDLE event;
-};
-
-class EventQueue : public QInternalList<QWaitConditionEvent>
-{
- public:
- EventQueue() { setAutoDelete(TRUE); }
- ~EventQueue() {}
-};
-
-class QWaitConditionPrivate
-{
-public:
- QMutex mtx;
- EventQueue queue;
- EventQueue freeQueue;
-
- QWaitConditionEvent *pre();
- void wait(QWaitConditionEvent *wce);
- void post(QWaitConditionEvent *wce);
-};
-
-QWaitConditionEvent *QWaitConditionPrivate::pre()
-{
- mtx.lock();
- QWaitConditionEvent *wce =
- freeQueue.isEmpty() ? new QWaitConditionEvent : freeQueue.take(0);
- wce->priority = GetThreadPriority(GetCurrentThread());
- wce->wokenUp = FALSE;
-
- // insert 'wce' into the queue (sorted by priority)
- uint index = 0;
- for (; index < queue.count(); ++index)
- {
- QWaitConditionEvent *current = queue.at(index);
- if (current->priority < wce->priority)
- break;
- }
- queue.insert(index, wce);
- mtx.unlock();
-
- return wce;
-}
-
-void QWaitConditionPrivate::wait(QWaitConditionEvent *wce)
-{
- WaitForSingleObject(wce->event, INFINITE);
-}
-
-void QWaitConditionPrivate::post(QWaitConditionEvent *wce)
-{
- mtx.lock();
-
- // remove 'wce' from the queue
- int idx = queue.find(wce);
- ASSERT(idx!=-1);
- queue.take(idx);
- ResetEvent(wce->event);
- freeQueue.append(wce);
-
- // wakeups delivered after the timeout should be forwarded to the next waiter
- if (wce->wokenUp && !queue.isEmpty())
- {
- QWaitConditionEvent *other = queue.getFirst();
- SetEvent(other->event);
- other->wokenUp = TRUE;
- }
-
- mtx.unlock();
-}
-
-//***********************************************************************
-// QWaitCondition implementation
-//***********************************************************************
-
-QWaitCondition::QWaitCondition()
-{
- d = new QWaitConditionPrivate;
-}
-
-QWaitCondition::~QWaitCondition()
-{
- if (!d->queue.isEmpty())
- {
- qWarning("QWaitCondition: Destroyed while threads are still waiting");
- }
- delete d;
-}
-
-void QWaitCondition::wait(QMutex *mutex)
-{
- if (!mutex) return;
-
- QWaitConditionEvent *wce = d->pre();
- mutex->unlock();
- d->wait(wce);
- mutex->lock();
- d->post(wce);
-}
-
-void QWaitCondition::wakeOne()
-{
- // wake up the first waiting thread in the queue
- QMutexLocker locker(&d->mtx);
- for (uint i = 0; i < d->queue.count(); ++i)
- {
- QWaitConditionEvent *current = d->queue.at(i);
- if (current->wokenUp) continue;
- SetEvent(current->event);
- current->wokenUp = TRUE;
- break;
- }
-}
-
-void QWaitCondition::wakeAll()
-{
- // wake up the all threads in the queue
- QMutexLocker locker(&d->mtx);
- for (uint i = 0; i < d->queue.count(); ++i)
- {
- QWaitConditionEvent *current = d->queue.at(i);
- SetEvent(current->event);
- current->wokenUp = TRUE;
- }
-}
-
diff --git a/src/configimpl.l b/src/configimpl.l
index 055304d..39f60e4 100644
--- a/src/configimpl.l
+++ b/src/configimpl.l
@@ -33,8 +33,8 @@
#include <qregexp.h>
#include <qstack.h>
#include <qglobal.h>
-#include <qthread.h>
-
+#include <thread>
+
#include "configimpl.h"
#include "version.h"
#include "portable.h"
@@ -1681,7 +1681,7 @@ void Config::checkAndCorrect()
}
else if (dotNumThreads<=0)
{
- dotNumThreads=QMAX(2,QThread::idealThreadCount()+1);
+ dotNumThreads=QMAX(2,std::thread::hardware_concurrency()+1);
}
// check dot path
diff --git a/src/dot.cpp b/src/dot.cpp
index f26bee4..acf4db9 100644
--- a/src/dot.cpp
+++ b/src/dot.cpp
@@ -83,10 +83,8 @@ DotManager *DotManager::instance()
return m_theInstance;
}
-DotManager::DotManager() : m_runners(1009), m_filePatchers(1009)
+DotManager::DotManager() : m_runners(), m_filePatchers()
{
- m_runners.setAutoDelete(TRUE);
- m_filePatchers.setAutoDelete(TRUE);
m_queue = new DotRunnerQueue;
int i;
int dotNumThreads = Config_getInt(DOT_NUM_THREADS);
@@ -114,40 +112,44 @@ DotManager::~DotManager()
delete m_queue;
}
-DotRunner* DotManager::createRunner(const QCString& absDotName, const QCString& md5Hash)
+DotRunner* DotManager::createRunner(const std::string &absDotName, const std::string& md5Hash)
{
- DotRunner * run = m_runners.find(absDotName);
- if (run == 0)
+ DotRunner* rv = nullptr;
+ auto const runit = m_runners.find(absDotName);
+ if (runit == m_runners.end())
{
- run = new DotRunner(absDotName, md5Hash);
- m_runners.insert(absDotName, run);
+ auto insobj = std::make_unique<DotRunner>(absDotName, md5Hash);
+ rv = insobj.get();
+ m_runners.emplace(absDotName, std::move(insobj));
}
else
{
// we have a match
- if (md5Hash != QCString(run->getMd5Hash().data()))
+ if (md5Hash != runit->second->getMd5Hash())
{
err("md5 hash does not match for two different runs of %s !\n", absDotName.data());
}
+ rv = runit->second.get();
}
- return run;
+ assert(rv);
+ return rv;
}
-DotFilePatcher *DotManager::createFilePatcher(const QCString &fileName)
+DotFilePatcher *DotManager::createFilePatcher(const std::string &fileName)
{
- DotFilePatcher *patcher = m_filePatchers.find(fileName);
- if (patcher==0)
- {
- patcher = new DotFilePatcher(fileName);
- m_filePatchers.append(fileName,patcher);
- }
- return patcher;
+ auto patcher = m_filePatchers.find(fileName);
+
+ if (patcher != m_filePatchers.end()) return &(patcher->second);
+
+ auto rv = m_filePatchers.emplace(fileName, fileName.c_str());
+ assert(rv.second);
+ return &(rv.first->second);
}
bool DotManager::run() const
{
- uint numDotRuns = m_runners.count();
- uint numFilePatchers = m_filePatchers.count();
+ uint numDotRuns = m_runners.size();
+ uint numFilePatchers = m_filePatchers.size();
if (numDotRuns+numFilePatchers>1)
{
if (m_workers.count()==0)
@@ -160,7 +162,6 @@ bool DotManager::run() const
}
}
int i=1;
- QDictIterator<DotRunner> li(m_runners);
bool setPath=FALSE;
if (Config_getBool(GENERATE_HTML))
@@ -185,22 +186,21 @@ bool DotManager::run() const
}
Portable::sysTimerStart();
// fill work queue with dot operations
- DotRunner *dr;
int prev=1;
if (m_workers.count()==0) // no threads to work with
{
- for (li.toFirst();(dr=li.current());++li)
+ for (auto & dr : m_runners)
{
msg("Running dot for graph %d/%d\n",prev,numDotRuns);
- dr->run();
+ dr.second->run();
prev++;
}
}
else // use multiple threads to run instances of dot in parallel
{
- for (li.toFirst();(dr=li.current());++li)
+ for (auto & dr: m_runners)
{
- m_queue->enqueue(dr);
+ m_queue->enqueue(dr.second.get());
}
// wait for the queue to become empty
while ((i=m_queue->count())>0)
@@ -237,27 +237,25 @@ bool DotManager::run() const
// patch the output file and insert the maps and figures
i=1;
- SDict<DotFilePatcher>::Iterator di(m_filePatchers);
- const DotFilePatcher *fp;
// since patching the svg files may involve patching the header of the SVG
// (for zoomable SVGs), and patching the .html files requires reading that
// header after the SVG is patched, we first process the .svg files and
// then the other files.
- for (di.toFirst();(fp=di.current());++di)
+ for (auto & fp : m_filePatchers)
{
- if (fp->isSVGFile())
+ if (fp.second.isSVGFile())
{
msg("Patching output file %d/%d\n",i,numFilePatchers);
- if (!fp->run()) return FALSE;
+ if (!fp.second.run()) return FALSE;
i++;
}
}
- for (di.toFirst();(fp=di.current());++di)
+ for (auto& fp : m_filePatchers)
{
- if (!fp->isSVGFile())
+ if (!fp.second.isSVGFile())
{
msg("Patching output file %d/%d\n",i,numFilePatchers);
- if (!fp->run()) return FALSE;
+ if (!fp.second.run()) return FALSE;
i++;
}
}
@@ -280,7 +278,7 @@ void writeDotGraphFromFile(const char *inFile,const char *outDir,
QCString absImgName = d.absPath().utf8()+"/"+imgName;
QCString absOutFile = d.absPath().utf8()+"/"+outFile;
- DotRunner dotRun(inFile, QCString());
+ DotRunner dotRun(inFile);
if (format==GOF_BITMAP)
{
dotRun.addJob(Config_getEnum(DOT_IMAGE_FORMAT),absImgName);
@@ -333,7 +331,7 @@ void writeDotImageMapFromFile(FTextStream &t,
QCString imgName = baseName+"."+imgExt;
QCString absOutFile = d.absPath().utf8()+"/"+mapName;
- DotRunner dotRun(inFile, QCString());
+ DotRunner dotRun(inFile.data());
dotRun.addJob(MAP_CMD,absOutFile);
dotRun.preventCleanUp();
if (!dotRun.run())
diff --git a/src/dot.h b/src/dot.h
index 60f7f26..3c9af66 100644
--- a/src/dot.h
+++ b/src/dot.h
@@ -17,8 +17,8 @@
#define DOT_H
#include <qlist.h>
-#include <qdict.h>
#include <qcstring.h>
+#include <map>
#include "sortdict.h"
@@ -35,16 +35,16 @@ class DotManager
{
public:
static DotManager *instance();
- DotRunner* createRunner(const QCString& absDotName, const QCString& md5Hash);
- DotFilePatcher *createFilePatcher(const QCString &fileName);
+ DotRunner* createRunner(const std::string& absDotName, const std::string& md5Hash);
+ DotFilePatcher *createFilePatcher(const std::string &fileName);
bool run() const;
private:
DotManager();
virtual ~DotManager();
- QDict<DotRunner> m_runners;
- SDict<DotFilePatcher> m_filePatchers;
+ std::map<std::string, std::unique_ptr<DotRunner>> m_runners;
+ std::map<std::string, DotFilePatcher> m_filePatchers;
static DotManager *m_theInstance;
DotRunnerQueue *m_queue;
QList<DotWorkerThread> m_workers;
diff --git a/src/dotgraph.cpp b/src/dotgraph.cpp
index 0bfa712..e622dd4 100644
--- a/src/dotgraph.cpp
+++ b/src/dotgraph.cpp
@@ -186,14 +186,14 @@ bool DotGraph::prepareDotFile()
if (m_graphFormat == GOF_BITMAP)
{
// run dot to create a bitmap image
- DotRunner * dotRun = DotManager::instance()->createRunner(absDotName(), sigStr);
+ DotRunner * dotRun = DotManager::instance()->createRunner(absDotName().data(), sigStr.data());
dotRun->addJob(Config_getEnum(DOT_IMAGE_FORMAT), absImgName());
if (m_generateImageMap) dotRun->addJob(MAP_CMD, absMapName());
}
else if (m_graphFormat == GOF_EPS)
{
// run dot to create a .eps image
- DotRunner *dotRun = DotManager::instance()->createRunner(absDotName(), sigStr);
+ DotRunner *dotRun = DotManager::instance()->createRunner(absDotName().data(), sigStr.data());
if (Config_getBool(USE_PDFLATEX))
{
dotRun->addJob("pdf",absImgName());
@@ -233,11 +233,11 @@ void DotGraph::generateCode(FTextStream &t)
if (m_regenerate)
{
DotManager::instance()->
- createFilePatcher(absImgName())->
+ createFilePatcher(absImgName().data())->
addSVGConversion(m_relPath,FALSE,QCString(),m_zoomable,m_graphId);
}
int mapId = DotManager::instance()->
- createFilePatcher(m_fileName)->
+ createFilePatcher(m_fileName.data())->
addSVGObject(m_baseName,absImgName(),m_relPath);
t << "<!-- SVG " << mapId << " -->" << endl;
}
@@ -252,7 +252,7 @@ void DotGraph::generateCode(FTextStream &t)
if (m_regenerate || !insertMapFile(t, absMapName(), m_relPath, getMapLabel()))
{
int mapId = DotManager::instance()->
- createFilePatcher(m_fileName)->
+ createFilePatcher(m_fileName.data())->
addMap(absMapName(), m_relPath, m_urlOnly, QCString(), getMapLabel());
t << "<!-- MAP " << mapId << " -->" << endl;
}
@@ -263,7 +263,7 @@ void DotGraph::generateCode(FTextStream &t)
if (m_regenerate || !DotFilePatcher::writeVecGfxFigure(t,m_baseName,absBaseName()))
{
int figId = DotManager::instance()->
- createFilePatcher(m_fileName)->
+ createFilePatcher(m_fileName.data())->
addFigure(m_baseName,absBaseName(),FALSE /*TRUE*/);
t << endl << "% FIG " << figId << endl;
}
diff --git a/src/dotlegendgraph.cpp b/src/dotlegendgraph.cpp
index 98e1f88..b17a293 100644
--- a/src/dotlegendgraph.cpp
+++ b/src/dotlegendgraph.cpp
@@ -29,7 +29,7 @@ void DotLegendGraph::writeGraph(const char *path)
if (getDotImageExtension()=="svg")
{
DotManager::instance()->
- createFilePatcher(absBaseName()+Config_getString(HTML_FILE_EXTENSION))->
+ createFilePatcher((absBaseName()+Config_getString(HTML_FILE_EXTENSION)).data())->
addSVGObject("graph_legend", absImgName(),QCString());
}
}
diff --git a/src/dotrunner.cpp b/src/dotrunner.cpp
index fc9f85c..cb6bd73 100644
--- a/src/dotrunner.cpp
+++ b/src/dotrunner.cpp
@@ -15,6 +15,7 @@
#include "dotrunner.h"
+#include "qstring.h"
#include "util.h"
#include "portable.h"
#include "dot.h"
@@ -145,31 +146,31 @@ bool DotRunner::readBoundingBox(const char *fileName,int *width,int *height,bool
//---------------------------------------------------------------------------------
-DotRunner::DotRunner(const QCString& absDotName, const QCString& md5Hash)
- : m_file(absDotName)
- , m_md5Hash(md5Hash)
+DotRunner::DotRunner(const std::string& absDotName, const std::string& md5Hash)
+ : m_file(absDotName.data())
+ , m_md5Hash(md5Hash.data())
, m_dotExe(Config_getString(DOT_PATH)+"dot")
, m_cleanUp(Config_getBool(DOT_CLEANUP))
+ , m_jobs()
{
- m_jobs.setAutoDelete(TRUE);
}
-void DotRunner::addJob(const char *format,const char *output)
+
+void DotRunner::addJob(const char *format, const char *output)
{
- QListIterator<DotJob> li(m_jobs);
- DotJob *s;
- for (li.toFirst(); (s = li.current()); ++li)
+
+ for (auto& s: m_jobs)
{
- if (qstrcmp(s->format.data(), format) != 0) continue;
- if (qstrcmp(s->output.data(), output) != 0) continue;
+ if (s.format != format) continue;
+ if (s.output != output) continue;
// we have this job already
return;
}
- QCString args = QCString("-T")+format+" -o \""+output+"\"";
- m_jobs.append(new DotJob(format, output, args));
+ auto args = std::string ("-T") + format + " -o \"" + output + "\"";
+ m_jobs.emplace_back(format, output, args);
}
-QCString getBaseNameOfOutput(QCString const& output)
+QCString getBaseNameOfOutput(const QCString &output)
{
int index = output.findRev('.');
if (index < 0) return output;
@@ -181,48 +182,46 @@ bool DotRunner::run()
int exitCode=0;
QCString dotArgs;
- QListIterator<DotJob> li(m_jobs);
- DotJob *s;
// create output
if (Config_getBool(DOT_MULTI_TARGETS))
{
dotArgs=QCString("\"")+m_file.data()+"\"";
- for (li.toFirst();(s=li.current());++li)
+ for (auto& s: m_jobs)
{
dotArgs+=' ';
- dotArgs+=s->args.data();
+ dotArgs+=s.args.data();
}
if ((exitCode=Portable::system(m_dotExe.data(),dotArgs,FALSE))!=0) goto error;
}
else
{
- for (li.toFirst();(s=li.current());++li)
+ for (auto& s : m_jobs)
{
- dotArgs=QCString("\"")+m_file.data()+"\" "+s->args.data();
+ dotArgs=QCString("\"")+m_file.data()+"\" "+s.args.data();
if ((exitCode=Portable::system(m_dotExe.data(),dotArgs,FALSE))!=0) goto error;
}
}
// check output
// As there should be only one pdf file be generated, we don't need code for regenerating multiple pdf files in one call
- for (li.toFirst();(s=li.current());++li)
+ for (auto& s : m_jobs)
{
- if (qstrncmp(s->format.data(), "pdf", 3) == 0)
+ if (s.format.compare(0, 3, "pdf") == 0)
{
int width=0,height=0;
- if (!readBoundingBox(s->output.data(),&width,&height,FALSE)) goto error;
+ if (!readBoundingBox(s.output.data(),&width,&height,FALSE)) goto error;
if ((width > MAX_LATEX_GRAPH_SIZE) || (height > MAX_LATEX_GRAPH_SIZE))
{
- if (!resetPDFSize(width,height,getBaseNameOfOutput(s->output.data()))) goto error;
- dotArgs=QCString("\"")+m_file.data()+"\" "+s->args.data();
+ if (!resetPDFSize(width,height,getBaseNameOfOutput(s.output.data()))) goto error;
+ dotArgs=QCString("\"")+m_file.data()+"\" "+s.args.data();
if ((exitCode=Portable::system(m_dotExe.data(),dotArgs,FALSE))!=0) goto error;
}
}
- if (qstrncmp(s->format.data(), "png", 3) == 0)
+ if (s.format.compare(0, 3, "png") == 0)
{
- checkPngResult(s->output.data());
+ checkPngResult(s.output.data());
}
}
@@ -234,7 +233,7 @@ bool DotRunner::run()
}
// create checksum file
- if (!m_md5Hash.isEmpty())
+ if (!m_md5Hash.empty())
{
QCString md5Name = getBaseNameOfOutput(m_file.data()) + ".md5";
FILE *f = Portable::fopen(md5Name,"w");
@@ -256,27 +255,27 @@ error:
void DotRunnerQueue::enqueue(DotRunner *runner)
{
- QMutexLocker locker(&m_mutex);
- m_queue.enqueue(runner);
- m_bufferNotEmpty.wakeAll();
+ std::lock_guard<std::mutex> locker(m_mutex);
+ m_queue.push(runner);
+ m_bufferNotEmpty.notify_all();
}
DotRunner *DotRunnerQueue::dequeue()
{
- QMutexLocker locker(&m_mutex);
- while (m_queue.isEmpty())
- {
- // wait until something is added to the queue
- m_bufferNotEmpty.wait(&m_mutex);
- }
- DotRunner *result = m_queue.dequeue();
+ std::unique_lock<std::mutex> locker(m_mutex);
+
+ // wait until something is added to the queue
+ m_bufferNotEmpty.wait(locker, [this]() { return !m_queue.empty(); });
+
+ DotRunner *result = m_queue.front();
+ m_queue.pop();
return result;
}
uint DotRunnerQueue::count() const
{
- QMutexLocker locker(&m_mutex);
- return m_queue.count();
+ std::lock_guard<std::mutex> locker(m_mutex);
+ return m_queue.size();
}
//--------------------------------------------------------------------
@@ -294,3 +293,9 @@ void DotWorkerThread::run()
runner->run();
}
}
+
+void DotWorkerThread::start()
+{
+ assert(!m_thread);
+ m_thread = std::make_unique<std::thread>(&DotWorkerThread::run, this);
+}
diff --git a/src/dotrunner.h b/src/dotrunner.h
index 1b68c18..555ea78 100644
--- a/src/dotrunner.h
+++ b/src/dotrunner.h
@@ -16,70 +16,30 @@
#ifndef DOTRUNNER_H
#define DOTRUNNER_H
-#include "qcstring.h"
-#include "qlist.h"
-#include "qwaitcondition.h"
-#include "qthread.h"
-#include "qqueue.h"
-#include "qmutex.h"
-
-/** Minimal constant string class that is thread safe, once initialized. */
-class DotConstString
-{
- public:
- DotConstString() { m_str=0;}
- ~DotConstString() { delete[] m_str;}
- DotConstString(char const* s) : m_str(0) { set(s); }
- DotConstString(const QCString &s) : m_str(0) { set(s); }
- DotConstString(const DotConstString &s) : m_str(0) { set(s.data()); }
- const char *data() const { return m_str; }
- bool isEmpty() const { return m_str==0 || m_str[0]=='\0'; }
-
- private:
- void set(char const* s)
- {
- delete[] m_str;
- m_str=0;
- if (s)
- {
- m_str=new char[strlen(s) + 1];
- qstrcpy(m_str,s);
- }
- }
-
- void set(const QCString &s)
- {
- delete[] m_str;
- m_str=0;
- if (!s.isEmpty())
- {
- m_str=new char[s.length()+1];
- qstrcpy(m_str,s.data());
- }
- }
-
- DotConstString &operator=(const DotConstString &);
-
- char *m_str;
-};
+#include <qglobal.h> //uint
+#include <string>
+#include <thread>
+#include <list>
+#include <queue>
+#include <mutex>
+#include <condition_variable>
+#include <memory>
/** Helper class to run dot from doxygen from multiple threads. */
class DotRunner
{
- public:
struct DotJob
{
- DotJob(const DotConstString & format,
- const DotConstString & output,
- const DotConstString & args)
- : format(format), output(output), args(args) {}
- DotConstString format;
- DotConstString output;
- DotConstString args;
+ DotJob(std::string f, std::string o, std::string a)
+ : format(f), output(o), args(a) {}
+ std::string format;
+ std::string output;
+ std::string args;
};
+ public:
/** Creates a runner for a dot \a file. */
- DotRunner(const QCString& absDotName, const QCString& md5Hash);
+ DotRunner(const std::string& absDotName, const std::string& md5Hash = std::string());
/** Adds an additional job to the run.
* Performing multiple jobs one file can be faster.
@@ -87,22 +47,22 @@ class DotRunner
void addJob(const char *format,const char *output);
/** Prevent cleanup of the dot file (for user provided dot files) */
- void preventCleanUp() { m_cleanUp = FALSE; }
+ void preventCleanUp() { m_cleanUp = false; }
/** Runs dot for all jobs added. */
bool run();
// DotConstString const& getFileName() { return m_file; }
- DotConstString const& getMd5Hash() { return m_md5Hash; }
+ std::string const & getMd5Hash() { return m_md5Hash; }
static bool readBoundingBox(const char* fileName, int* width, int* height, bool isEps);
private:
- DotConstString m_file;
- DotConstString m_md5Hash;
- DotConstString m_dotExe;
- bool m_cleanUp;
- QList<DotJob> m_jobs;
+ std::string m_file;
+ std::string m_md5Hash;
+ std::string m_dotExe;
+ bool m_cleanUp;
+ std::vector<DotJob> m_jobs;
};
/** Queue of dot jobs to run. */
@@ -114,18 +74,22 @@ class DotRunnerQueue
DotRunner *dequeue();
uint count() const;
private:
- QWaitCondition m_bufferNotEmpty;
- QQueue<DotRunner> m_queue;
- mutable QMutex m_mutex;
+ std::condition_variable m_bufferNotEmpty;
+ std::queue<DotRunner *> m_queue;
+ mutable std::mutex m_mutex;
};
/** Worker thread to execute a dot run */
-class DotWorkerThread : public QThread
+class DotWorkerThread
{
public:
DotWorkerThread(DotRunnerQueue *queue);
void run();
+ void start();
+ bool isRunning() { return m_thread && m_thread->joinable(); }
+ void wait() { m_thread->join(); }
private:
+ std::unique_ptr<std::thread> m_thread;
DotRunnerQueue *m_queue;
};
diff --git a/src/tclscanner.l b/src/tclscanner.l
index 10aba97..2e15fc5 100644
--- a/src/tclscanner.l
+++ b/src/tclscanner.l
@@ -1173,6 +1173,7 @@ tcl_inf("line=%d type=%d '%s'\n",tcl.line_body0,type,content.data());
myScan->type[0] = type;
break;
case '?':
+ if (content.isEmpty()) break;
if (content[0]=='"' && content[content.length()-1]=='"') myScan->type[0]='"';
if (content[0]=='{' && content[content.length()-1]=='}') myScan->type[0]='{';
if (content[0]=='[' && content[content.length()-1]==']') myScan->type[0]='[';