00001 /* 00002 ============================================================================== 00003 00004 This file is part of the JUCE library - "Jules' Utility Class Extensions" 00005 Copyright 2004-7 by Raw Material Software ltd. 00006 00007 ------------------------------------------------------------------------------ 00008 00009 JUCE can be redistributed and/or modified under the terms of the 00010 GNU General Public License, as published by the Free Software Foundation; 00011 either version 2 of the License, or (at your option) any later version. 00012 00013 JUCE is distributed in the hope that it will be useful, 00014 but WITHOUT ANY WARRANTY; without even the implied warranty of 00015 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00016 GNU General Public License for more details. 00017 00018 You should have received a copy of the GNU General Public License 00019 along with JUCE; if not, visit www.gnu.org/licenses or write to the 00020 Free Software Foundation, Inc., 59 Temple Place, Suite 330, 00021 Boston, MA 02111-1307 USA 00022 00023 ------------------------------------------------------------------------------ 00024 00025 If you'd like to release a closed-source product which uses JUCE, commercial 00026 licenses are also available: visit www.rawmaterialsoftware.com/juce for 00027 more information. 00028 00029 ============================================================================== 00030 */ 00031 00032 #ifndef __JUCE_CRITICALSECTION_JUCEHEADER__ 00033 #define __JUCE_CRITICALSECTION_JUCEHEADER__ 00034 00035 00036 //============================================================================== 00042 class JUCE_API CriticalSection 00043 { 00044 public: 00045 //============================================================================== 00049 CriticalSection() throw(); 00050 00056 ~CriticalSection() throw(); 00057 00058 //============================================================================== 00068 void enter() const throw(); 00069 00078 bool tryEnter() const throw(); 00079 00090 void exit() const throw(); 00091 00092 00093 //============================================================================== 00094 juce_UseDebuggingNewOperator 00095 00096 private: 00097 //============================================================================== 00098 #if JUCE_WIN32 00099 #if JUCE_64BIT 00100 // To avoid including windows.h in the public Juce includes, we'll just allocate a 00101 // block of memory here that's big enough to be used internally as a windows critical 00102 // section object. 00103 uint8 internal [44]; 00104 #else 00105 uint8 internal [24]; 00106 #endif 00107 #else 00108 mutable pthread_mutex_t internal; 00109 #endif 00110 00111 CriticalSection (const CriticalSection&); 00112 const CriticalSection& operator= (const CriticalSection&); 00113 }; 00114 00115 00116 //============================================================================== 00125 class JUCE_API DummyCriticalSection 00126 { 00127 public: 00128 forcedinline DummyCriticalSection() throw() {} 00129 forcedinline ~DummyCriticalSection() throw() {} 00130 00131 forcedinline void enter() const throw() {} 00132 forcedinline void exit() const throw() {} 00133 }; 00134 00135 00136 #endif // __JUCE_CRITICALSECTION_JUCEHEADER__