• Skip to content
  • Skip to link menu
KDE 4.4 API Reference
  • KDE API Reference
  • KDevelop Platform Libraries
  • Sitemap
  • Contact Us
 

language/duchain

duchainlock.h

00001 /* This file is part of KDevelop
00002     Copyright 2007 Kris Wong <kris.p.wong@gmail.com>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License version 2 as published by the Free Software Foundation.
00007 
00008    This library is distributed in the hope that it will be useful,
00009    but WITHOUT ANY WARRANTY; without even the implied warranty of
00010    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011    Library General Public License for more details.
00012 
00013    You should have received a copy of the GNU Library General Public License
00014    along with this library; see the file COPYING.LIB.  If not, write to
00015    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00016    Boston, MA 02110-1301, USA.
00017 */
00018 
00019 #ifndef DUCHAINLOCK_H
00020 #define DUCHAINLOCK_H
00021 
00022 #include "../languageexport.h"
00023 
00024 namespace KDevelop
00025 {
00026 
00027 // #define NO_DUCHAIN_LOCK_TESTING
00028 
00036 #if !defined(NDEBUG) && !defined(NO_DUCHAIN_LOCK_TESTING)
00037 #define ENSURE_CHAIN_READ_LOCKED Q_ASSERT(DUChain::lock()->currentThreadHasReadLock() || DUChain::lock()->currentThreadHasWriteLock());
00038 #define ENSURE_CHAIN_WRITE_LOCKED Q_ASSERT(DUChain::lock()->currentThreadHasWriteLock());
00039 #else
00040 #define ENSURE_CHAIN_READ_LOCKED
00041 #define ENSURE_CHAIN_WRITE_LOCKED
00042 #endif
00043 
00047 class KDEVPLATFORMLANGUAGE_EXPORT DUChainLock
00048 {
00049 public:
00051   DUChainLock();
00053   ~DUChainLock();
00054 
00065   bool lockForRead(unsigned int timeout);
00066 
00076   bool lockForRead();
00077 
00081   void releaseReadLock();
00082 
00086   bool currentThreadHasReadLock();
00087 
00099   bool lockForWrite(uint timeout = 0);
00100 
00104   void releaseWriteLock();
00105 
00109   bool currentThreadHasWriteLock();
00110 
00111 private:
00112   class DUChainLockPrivate* const d;
00113 };
00114 
00118 class KDEVPLATFORMLANGUAGE_EXPORT DUChainReadLocker
00119 {
00120 public:
00127   DUChainReadLocker(DUChainLock* duChainLock, uint timeout = 0);
00128 
00130   ~DUChainReadLocker();
00131 
00133   bool lock();
00135   void unlock();
00136 
00138   bool locked() const;
00139 
00140 private:
00141   DUChainLock* m_lock;
00142   bool m_locked;
00143   uint m_timeout;
00144 };
00145 
00149 class KDEVPLATFORMLANGUAGE_EXPORT DUChainWriteLocker
00150 {
00151 public:
00158   DUChainWriteLocker(DUChainLock* duChainLock, uint timeout = 0);
00160   ~DUChainWriteLocker();
00161 
00163   bool lock();
00165   void unlock();
00166 
00168   bool locked() const;
00169 
00170 private:
00171   class DUChainWriteLockerPrivate* const d;
00172 };
00173 
00179 #if !defined(NDEBUG) && !defined(NO_DUCHAIN_LOCK_TESTING)
00180 #define ENSURE_CAN_WRITE {if( inDUChain()) { ENSURE_CHAIN_WRITE_LOCKED }}
00181 #define ENSURE_CAN_READ {if( inDUChain()) { ENSURE_CHAIN_READ_LOCKED }}
00182 #else
00183 #define ENSURE_CAN_WRITE
00184 #define ENSURE_CAN_READ
00185 #endif
00186 
00187 }
00188 
00189 #endif // DUCHAINLOCK_H
00190 
00191 // kate: space-indent on; indent-width 2; tab-width 4; replace-tabs on; auto-insert-doxygen on

language/duchain

Skip menu "language/duchain"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

KDevelop Platform Libraries

Skip menu "KDevelop Platform Libraries"
  • interfaces
  • language
  •   codegen
  •   duchain
  •   editor
  • outputview
  • project
  • shell
  • sublime
  • util
  • vcs
Generated for KDevelop Platform Libraries by doxygen 1.5.9-20090814
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal