OpenShot Audio Library | OpenShotAudio 0.3.2

Loading...
Searching...
No Matches
juce_CriticalSection.h
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2017 - ROLI Ltd.
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 The code included in this file is provided under the terms of the ISC license
11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission
12 To use, copy, modify, and/or distribute this software for any purpose with or
13 without fee is hereby granted provided that the above copyright notice and
14 this permission notice appear in all copies.
15
16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
18 DISCLAIMED.
19
20 ==============================================================================
21*/
22
23 namespace juce
24{
25
26//==============================================================================
42 class JUCE_API CriticalSection
43{
44 public:
45 //==============================================================================
47 CriticalSection() noexcept;
48
53 ~CriticalSection() noexcept;
54
55 //==============================================================================
66 void enter() const noexcept;
67
76 bool tryEnter() const noexcept;
77
88 void exit() const noexcept;
89
90
91 //==============================================================================
93 using ScopedLockType = GenericScopedLock<CriticalSection>;
94
96 using ScopedUnlockType = GenericScopedUnlock<CriticalSection>;
97
99 using ScopedTryLockType = GenericScopedTryLock<CriticalSection>;
100
101
102private:
103 //==============================================================================
104 #if JUCE_WINDOWS
105 // To avoid including windows.h in the public JUCE headers, we'll just allocate
106 // a block of memory here that's big enough to be used internally as a windows
107 // CRITICAL_SECTION structure.
108 #if JUCE_64BIT
109 uint8 lock[44];
110 #else
111 uint8 lock[24];
112 #endif
113 #else
114 mutable pthread_mutex_t lock;
115 #endif
116
117 JUCE_DECLARE_NON_COPYABLE (CriticalSection)
118};
119
120
121//==============================================================================
133 class JUCE_API DummyCriticalSection
134{
135 public:
136 inline DummyCriticalSection() = default;
137 inline ~DummyCriticalSection() = default;
138
139 inline void enter() const noexcept {}
140 inline bool tryEnter() const noexcept { return true; }
141 inline void exit() const noexcept {}
142
143 //==============================================================================
145 struct ScopedLockType
146 {
147 ScopedLockType (const DummyCriticalSection&) noexcept {}
148 };
149
151 using ScopedUnlockType = ScopedLockType;
152
153 private:
154 JUCE_DECLARE_NON_COPYABLE (DummyCriticalSection)
155};
156
157//==============================================================================
186 using ScopedLock = CriticalSection::ScopedLockType;
187
188//==============================================================================
226 using ScopedUnlock = CriticalSection::ScopedUnlockType;
227
228//==============================================================================
260 using ScopedTryLock = CriticalSection::ScopedTryLockType;
261
262} // namespace juce
juce::CriticalSection
Definition: juce_CriticalSection.h:43
juce::CriticalSection::ScopedLockType
GenericScopedLock< CriticalSection > ScopedLockType
Definition: juce_CriticalSection.h:93
juce::CriticalSection::ScopedUnlockType
GenericScopedUnlock< CriticalSection > ScopedUnlockType
Definition: juce_CriticalSection.h:96
juce::CriticalSection::CriticalSection
CriticalSection() noexcept
juce::CriticalSection::ScopedTryLockType
GenericScopedTryLock< CriticalSection > ScopedTryLockType
Definition: juce_CriticalSection.h:99
juce::DummyCriticalSection
Definition: juce_CriticalSection.h:134
juce::GenericScopedLock
Definition: juce_ScopedLock.h:55
juce::GenericScopedTryLock
Definition: juce_ScopedLock.h:198
juce::GenericScopedUnlock
Definition: juce_ScopedLock.h:126
juce::DummyCriticalSection::ScopedLockType
Definition: juce_CriticalSection.h:146