OpenShot Library | libopenshot-audio
0.2.0
|
33 jassert (readerThreads.
size() == 0);
34 jassert (numWriters == 0);
50 for (
int i = 0; i < readerThreads.
size(); ++i)
52 ThreadRecursionCount& trc = readerThreads.
getReference(i);
54 if (trc.threadID == threadId)
61 if (numWriters + numWaitingWriters == 0
62 || (threadId == writerThreadId && numWriters > 0))
64 ThreadRecursionCount trc = { threadId, 1 };
65 readerThreads.
add (trc);
77 for (
int i = 0; i < readerThreads.
size(); ++i)
79 ThreadRecursionCount& trc = readerThreads.
getReference(i);
81 if (trc.threadID == threadId)
83 if (--(trc.count) == 0)
102 while (! tryEnterWriteInternal (threadId))
106 waitEvent.
wait (100);
118 bool ReadWriteLock::tryEnterWriteInternal (
Thread::ThreadID threadId)
const noexcept
120 if (readerThreads.size() + numWriters == 0
121 || threadId == writerThreadId
122 || (readerThreads.size() == 1 && readerThreads.getReference(0).threadID == threadId))
124 writerThreadId = threadId;
139 if (--numWriters == 0)
~ReadWriteLock() noexcept
Destructor.
int size() const noexcept
Returns the current number of elements in the array.
void exitWrite() const noexcept
Releases the write-lock.
void enterRead() const noexcept
Locks this object for reading.
static ThreadID JUCE_CALLTYPE getCurrentThreadId()
Returns an id that identifies the caller thread.
void add(const ElementType &newElement)
Appends a new element at the end of the array.
void signal() const noexcept
Wakes up any threads that are currently waiting on this object.
void enterWrite() const noexcept
Locks this object for writing.
void * ThreadID
A value type used for thread IDs.
void exit() const noexcept
Releases the lock.
ReadWriteLock() noexcept
Creates a ReadWriteLock object.
void enter() const noexcept
Acquires the lock.
void exitRead() const noexcept
Releases the read-lock.
bool wait(int timeOutMilliseconds=-1) const noexcept
Suspends the calling thread until the event has been signalled.
Automatically locks and unlocks a mutex object.
void ensureStorageAllocated(int minNumElements)
Increases the array's internal storage to hold a minimum number of elements.
void remove(int indexToRemove)
Removes an element from the array.
bool tryEnterWrite() const noexcept
Tries to lock this object for writing.
bool tryEnterRead() const noexcept
Tries to lock this object for reading.
ElementType & getReference(int index) const noexcept
Returns a direct reference to one of the elements in the array, without checking the index passed in.