Eneboo - Documentación para desarrolladores
src/qt/src/tools/qmutex.h
Ir a la documentación de este archivo.
00001 /****************************************************************************
00002 ** $Id: qt/qmutex.h   3.3.8   edited Jan 11 14:38 $
00003 **
00004 ** Definition of QMutex class
00005 **
00006 ** Created : 931107
00007 **
00008 ** Copyright (C) 1992-2007 Trolltech ASA.  All rights reserved.
00009 **
00010 ** This file is part of the tools module of the Qt GUI Toolkit.
00011 **
00012 ** This file may be distributed under the terms of the Q Public License
00013 ** as defined by Trolltech ASA of Norway and appearing in the file
00014 ** LICENSE.QPL included in the packaging of this file.
00015 **
00016 ** This file may be distributed and/or modified under the terms of the
00017 ** GNU General Public License version 2 as published by the Free Software
00018 ** Foundation and appearing in the file LICENSE.GPL included in the
00019 ** packaging of this file.
00020 **
00021 ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
00022 ** licenses may use this file in accordance with the Qt Commercial License
00023 ** Agreement provided with the Software.
00024 **
00025 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00026 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00027 **
00028 ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
00029 **   information about Qt Commercial License Agreements.
00030 ** See http://www.trolltech.com/qpl/ for QPL licensing information.
00031 ** See http://www.trolltech.com/gpl/ for GPL licensing information.
00032 **
00033 ** Contact info@trolltech.com if any conditions of this licensing are
00034 ** not clear to you.
00035 **
00036 **********************************************************************/
00037 
00038 #ifndef QMUTEX_H
00039 #define QMUTEX_H
00040 
00041 #ifndef QT_H
00042 #include "qglobal.h"
00043 #endif // QT_H
00044 
00045 #if defined(QT_THREAD_SUPPORT)
00046 
00047 class QMutexPrivate;
00048 
00049 const int Q_MUTEX_NORMAL = 0;
00050 const int Q_MUTEX_RECURSIVE = 1;
00051 
00052 class Q_EXPORT QMutex
00053 {
00054     friend class QThread;
00055     friend class QWaitCondition;
00056     friend class QWaitConditionPrivate;
00057 
00058 public:
00059     QMutex(bool recursive = FALSE);
00060     virtual ~QMutex();
00061 
00062     void lock();
00063     void unlock();
00064     bool locked();
00065     bool tryLock();
00066 
00067 private:
00068     QMutexPrivate * d;
00069 
00070 #if defined(Q_DISABLE_COPY)
00071     QMutex( const QMutex & );
00072     QMutex &operator=( const QMutex & );
00073 #endif
00074 };
00075 
00076 class Q_EXPORT QMutexLocker
00077 {
00078 public:
00079     QMutexLocker( QMutex * );
00080     ~QMutexLocker();
00081 
00082     QMutex *mutex() const;
00083 
00084 private:
00085     QMutex *mtx;
00086 
00087 #if defined(Q_DISABLE_COPY)
00088     QMutexLocker( const QMutexLocker & );
00089     QMutexLocker &operator=( const QMutexLocker & );
00090 #endif
00091 };
00092 
00093 inline QMutexLocker::QMutexLocker( QMutex *m )
00094     : mtx( m )
00095 {
00096     if ( mtx ) mtx->lock();
00097 }
00098 
00099 inline QMutexLocker::~QMutexLocker()
00100 {
00101     if ( mtx ) mtx->unlock();
00102 }
00103 
00104 inline QMutex *QMutexLocker::mutex() const
00105 {
00106     return mtx;
00107 }
00108 
00109 #endif
00110 
00111 #endif
 Todo Clases Namespaces Archivos Funciones Variables 'typedefs' Enumeraciones Valores de enumeraciones Propiedades Amigas 'defines'