| QxOrm 1.2.1 C++ Object Relational Mapping library

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Directories

- File List
- File Members

QxThreadPool.h
Go to the documentation of this file.

    00001 /****************************************************************************
    00002 **
    00003 ** http://www.qxorm.com/
    00004 ** http://sourceforge.net/projects/qxorm/
    00005 ** Original file by Lionel Marty
    00006 **
    00007 ** This file is part of the QxOrm library
    00008 **
    00009 ** This software is provided 'as-is', without any express or implied
    00010 ** warranty. In no event will the authors be held liable for any
    00011 ** damages arising from the use of this software.
    00012 **
    00013 ** GNU Lesser General Public License Usage
    00014 ** This file must be used under the terms of the GNU Lesser
    00015 ** General Public License version 2.1 as published by the Free Software
    00016 ** Foundation and appearing in the file 'license.lgpl.txt' included in the
    00017 ** packaging of this file.  Please review the following information to
    00018 ** ensure the GNU Lesser General Public License version 2.1 requirements
    00019 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
    00020 **
    00021 ** If you have questions regarding the use of this file, please contact :
    00022 ** contact@qxorm.com
    00023 **
    00024 ****************************************************************************/
    00025
    00026 #include <QxCommon/QxConfig.h> // Need to include this file for the 'moc' process
    00027
    00028 #if _QX_ENABLE_QT_NETWORK_DEPENDENCY
    00029 #ifndef _QX_SERVICE_THREAD_POOL_H_
    00030 #define _QX_SERVICE_THREAD_POOL_H_
    00031
    00032 #ifdef _MSC_VER
    00033 #pragma once
    00034 #endif
    00035
    00043 #include <QtCore/qqueue.h>
    00044
    00045 #include <QxService/QxTransaction.h>
    00046 #include <QxService/QxServer.h>
    00047
    00048 namespace qx {
    00049 namespace service {
    00050
    00051 class QxThread;
    00052
    00059 class QX_DLL_EXPORT QxThreadPool : public QThread
    00060 { Q_OBJECT
    00061
    00062 protected:
    00063
    00064    QList<QxThread *> m_lstAllServices;
    00065    QQueue<QxThread *> m_lstAvailable;
    00066    bool m_bIsRunning;
    00067    QMutex m_mutex;
    00068
    00069 public:
    00070
    00071    QxThreadPool() : QThread(), m_bIsRunning(false) { ; }
    00072    virtual ~QxThreadPool() { if (isRunning()) { qDebug("[QxOrm] qx::service::QxThreadPool thread is running : %s", "quit and wait"); quit(); wait(); } }
    00073
    00074    QxThread * getAvailable();
    00075    void setAvailable(QxThread * p);
    00076    void raiseError(const QString & err, QxTransaction_ptr transaction);
    00077
    00078    void sleepThread(unsigned long msecs) { QThread::msleep(msecs); }
    00079
    00080 protected:
    00081
    00082    virtual void run();
    00083
    00084    void runServer();
    00085    void initServices();
    00086    void clearServices();
    00087
    00088 Q_SIGNALS:
    00089
    00090    void error(const QString & err, qx::service::QxTransaction_ptr transaction);
    00091    void transactionStarted(qx::service::QxTransaction_ptr transaction);
    00092    void transactionFinished(qx::service::QxTransaction_ptr transaction);
    00093    void serverIsRunning(bool bIsRunning, qx::service::QxServer * pServer);
    00094
    00095 };
    00096
    00097 typedef boost::shared_ptr<QxThreadPool> QxThreadPool_ptr;
    00098
    00099 } // namespace service
    00100 } // namespace qx
    00101
    00102 #endif // _QX_SERVICE_THREAD_POOL_H_
    00103 #endif // _QX_ENABLE_QT_NETWORK_DEPENDENCY

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines