Add some thread classes and fix SharedData with a simple mutex adapter

This commit is contained in:
Vinnie Falco
2013-09-20 02:36:47 -07:00
parent 755ab36f0d
commit 9534516b42
17 changed files with 574 additions and 332 deletions

View File

@@ -299,7 +299,7 @@ public:
void stateChanged ()
{
SharedData <SharedState>::ReadAccess state (sharedState);
SharedData <SharedState>::ConstAccess state (sharedState);
// (read state)
}
@@ -308,7 +308,7 @@ public:
void changeState ()
{
SharedData <State>::WriteAccess state (sharedState);
SharedData <State>::Access state (sharedState);
// (read and write state)

View File

@@ -137,7 +137,7 @@
void addListener (Listener* listener, CallQueue& callQueue)
{
// Acquire read access to the shared state.
SharedData <State>::ReadAccess state (m_state);
SharedData <State>::ConstAccess state (m_state);
// Add the listener.
m_listeners.add (listener, callQueue);
@@ -171,7 +171,7 @@
// Update shared state.
{
SharedData <State>::WriteAccess state (m_state);
SharedData <State>::Access state (m_state);
m_state->outputLevel = newOutputLevel;
}

View File

@@ -205,7 +205,7 @@ bool TrackedMutex::Agent::getLockedList (Array <Record>& output)
{
TrackedMutex const& mutex = *iter;
{
TrackedMutex::SharedState::ReadAccess state (mutex.m_state);
TrackedMutex::SharedState::ConstAccess state (mutex.m_state);
output.add (state->owner);
}
}
@@ -237,7 +237,7 @@ String TrackedMutex::getName () const noexcept
TrackedMutex::Record TrackedMutex::getOwnerRecord () const noexcept
{
{
SharedState::ReadAccess state (m_state);
SharedState::ConstAccess state (m_state);
return state->owner;
}
}
@@ -245,7 +245,7 @@ TrackedMutex::Record TrackedMutex::getOwnerRecord () const noexcept
TrackedMutex::Agent TrackedMutex::getOwnerAgent () const noexcept
{
{
SharedState::ReadAccess state (m_state);
SharedState::ConstAccess state (m_state);
if (state->thread != nullptr)
return Agent (state->thread);
}
@@ -298,7 +298,7 @@ void TrackedMutex::generateGlobalBlockedReport (StringArray& report)
{
String s;
TrackedMutex const& mutex (*iter);
TrackedMutex::SharedState::ReadAccess state (mutex.m_state);
TrackedMutex::SharedState::ConstAccess state (mutex.m_state);
s << " " << mutex.getName () <<
" from " << state->owner.getSourceLocation ();
report.add (s);
@@ -372,7 +372,7 @@ void TrackedMutex::acquired (char const* fileName, int lineNumber) const noexcep
{
// Take a state lock.
SharedState::WriteAccess state (m_state);
SharedState::Access state (m_state);
// Set the mutex ownership record
state->owner = Record (getName (), threadName, sourceLocation);
@@ -428,7 +428,7 @@ void TrackedMutex::release () const noexcept
{
// Take the mutex' state lock
SharedState::WriteAccess state (m_state);
SharedState::Access state (m_state);
// Clear the mutex ownership record
state->owner = Record ();