OpenShot Library | libopenshot-audio
0.2.0
juce_ScopedWriteLock.h
1
2
/** @weakgroup juce_core-threads
3
* @{
4
*/
5
/*
6
==============================================================================
7
8
This file is part of the JUCE library.
9
Copyright (c) 2017 - ROLI Ltd.
10
11
JUCE is an open source library subject to commercial or open-source
12
licensing.
13
14
The code included in this file is provided under the terms of the ISC license
15
http://www.isc.org/downloads/software-support-policy/isc-license. Permission
16
To use, copy, modify, and/or distribute this software for any purpose with or
17
without fee is hereby granted provided that the above copyright notice and
18
this permission notice appear in all copies.
19
20
JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
21
EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
22
DISCLAIMED.
23
24
==============================================================================
25
*/
26
27
namespace
juce
28
{
29
30
//==============================================================================
31
/**
32
Automatically locks and unlocks a ReadWriteLock object.
33
34
Use one of these as a local variable to control access to a ReadWriteLock.
35
36
e.g. @code
37
38
ReadWriteLock myLock;
39
40
for (;;)
41
{
42
const ScopedWriteLock myScopedLock (myLock);
43
// myLock is now locked
44
45
...do some stuff...
46
47
// myLock gets unlocked here.
48
}
49
@endcode
50
51
@see ReadWriteLock, ScopedReadLock
52
53
@tags{Core}
54
*/
55
class
JUCE_API
ScopedWriteLock
56
{
57
public
:
58
//==============================================================================
59
/** Creates a ScopedWriteLock.
60
61
As soon as it is created, this will call ReadWriteLock::enterWrite(), and
62
when the ScopedWriteLock object is deleted, the ReadWriteLock will
63
be unlocked.
64
65
Make sure this object is created and deleted by the same thread,
66
otherwise there are no guarantees what will happen! Best just to use it
67
as a local stack object, rather than creating one with the new() operator.
68
*/
69
inline
explicit
ScopedWriteLock
(
const
ReadWriteLock
& lock) noexcept : lock_ (lock) { lock.enterWrite(); }
70
71
/** Destructor.
72
73
The ReadWriteLock's exitWrite() method will be called when the destructor is called.
74
75
Make sure this object is created and deleted by the same thread,
76
otherwise there are no guarantees what will happen!
77
*/
78
inline
~ScopedWriteLock
() noexcept { lock_.exitWrite(); }
79
80
81
private
:
82
//==============================================================================
83
const
ReadWriteLock
& lock_;
84
85
JUCE_DECLARE_NON_COPYABLE (
ScopedWriteLock
)
86
};
87
88
}
89
90
/** @}*/
juce::ScopedWriteLock::ScopedWriteLock
ScopedWriteLock(const ReadWriteLock &lock) noexcept
Creates a ScopedWriteLock.
Definition:
juce_ScopedWriteLock.h:69
JUCE_API
#define JUCE_API
This macro is added to all JUCE public class declarations.
Definition:
juce_StandardHeader.h:143
juce::ScopedWriteLock
Automatically locks and unlocks a ReadWriteLock object.
Definition:
juce_ScopedWriteLock.h:55
juce::ReadWriteLock
A critical section that allows multiple simultaneous readers.
Definition:
juce_ReadWriteLock.h:51
juce::ScopedWriteLock::~ScopedWriteLock
~ScopedWriteLock() noexcept
Destructor.
Definition:
juce_ScopedWriteLock.h:78
juce_core
threads
juce_ScopedWriteLock.h
Generated on Wed Jun 24 2020 20:19:20 for OpenShot Library | libopenshot-audio by
1.8.17