mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Remove ConcurrentObject and rename to SharedData
This commit is contained in:
@@ -78,8 +78,7 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_basics\memory\beast_GlobalPagedFreeStore.h" />
|
<ClInclude Include="..\..\modules\beast_basics\memory\beast_GlobalPagedFreeStore.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_basics\memory\beast_PagedFreeStore.h" />
|
<ClInclude Include="..\..\modules\beast_basics\memory\beast_PagedFreeStore.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_CallQueue.h" />
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_CallQueue.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_ConcurrentObject.h" />
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_SharedData.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_ConcurrentState.h" />
|
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_GlobalThreadGroup.h" />
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_GlobalThreadGroup.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_InterruptibleThread.h" />
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_InterruptibleThread.h" />
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_Listeners.h" />
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_Listeners.h" />
|
||||||
@@ -280,12 +279,6 @@
|
|||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\modules\beast_basics\threads\beast_ConcurrentObject.cpp">
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
|
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\modules\beast_basics\threads\beast_InterruptibleThread.cpp">
|
<ClCompile Include="..\..\modules\beast_basics\threads\beast_InterruptibleThread.cpp">
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
|
||||||
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
|
||||||
|
|||||||
@@ -503,12 +503,6 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_CallQueue.h">
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_CallQueue.h">
|
||||||
<Filter>beast_basics\threads</Filter>
|
<Filter>beast_basics\threads</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_ConcurrentObject.h">
|
|
||||||
<Filter>beast_basics\threads</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_ConcurrentState.h">
|
|
||||||
<Filter>beast_basics\threads</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\modules\beast_basics\threads\beast_GlobalThreadGroup.h">
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_GlobalThreadGroup.h">
|
||||||
<Filter>beast_basics\threads</Filter>
|
<Filter>beast_basics\threads</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
@@ -611,6 +605,9 @@
|
|||||||
<ClInclude Include="..\..\modules\beast_core\time\beast_PerformedAtExit.h">
|
<ClInclude Include="..\..\modules\beast_core\time\beast_PerformedAtExit.h">
|
||||||
<Filter>beast_core\time</Filter>
|
<Filter>beast_core\time</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
<ClInclude Include="..\..\modules\beast_basics\threads\beast_SharedData.h">
|
||||||
|
<Filter>beast_basics\threads</Filter>
|
||||||
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
|
||||||
@@ -889,9 +886,6 @@
|
|||||||
<ClCompile Include="..\..\modules\beast_basics\threads\beast_CallQueue.cpp">
|
<ClCompile Include="..\..\modules\beast_basics\threads\beast_CallQueue.cpp">
|
||||||
<Filter>beast_basics\threads</Filter>
|
<Filter>beast_basics\threads</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\modules\beast_basics\threads\beast_ConcurrentObject.cpp">
|
|
||||||
<Filter>beast_basics\threads</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\modules\beast_basics\threads\beast_InterruptibleThread.cpp">
|
<ClCompile Include="..\..\modules\beast_basics\threads\beast_InterruptibleThread.cpp">
|
||||||
<Filter>beast_basics\threads</Filter>
|
<Filter>beast_basics\threads</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
2
TODO.txt
2
TODO.txt
@@ -34,7 +34,7 @@ BEAST TODO
|
|||||||
|
|
||||||
- Clean up ConcurrentObject
|
- Clean up ConcurrentObject
|
||||||
|
|
||||||
- Rename ConcurrentState to SharedState or something?
|
- Rename SharedData to SharedState or something?
|
||||||
|
|
||||||
- Figure out what to do with ReadWriteLock, and NamedPipe which uses it?
|
- Figure out what to do with ReadWriteLock, and NamedPipe which uses it?
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ namespace beast
|
|||||||
#include "memory/beast_GlobalPagedFreeStore.cpp"
|
#include "memory/beast_GlobalPagedFreeStore.cpp"
|
||||||
#include "memory/beast_PagedFreeStore.cpp"
|
#include "memory/beast_PagedFreeStore.cpp"
|
||||||
#include "threads/beast_CallQueue.cpp"
|
#include "threads/beast_CallQueue.cpp"
|
||||||
#include "threads/beast_ConcurrentObject.cpp"
|
|
||||||
#include "threads/beast_Listeners.cpp"
|
#include "threads/beast_Listeners.cpp"
|
||||||
#include "threads/beast_ManualCallQueue.cpp"
|
#include "threads/beast_ManualCallQueue.cpp"
|
||||||
#include "threads/beast_ParallelFor.cpp"
|
#include "threads/beast_ParallelFor.cpp"
|
||||||
|
|||||||
@@ -263,8 +263,7 @@ namespace beast
|
|||||||
#include "threads/beast_ReadWriteMutex.h"
|
#include "threads/beast_ReadWriteMutex.h"
|
||||||
#include "threads/beast_ThreadGroup.h"
|
#include "threads/beast_ThreadGroup.h"
|
||||||
#include "threads/beast_CallQueue.h"
|
#include "threads/beast_CallQueue.h"
|
||||||
#include "threads/beast_ConcurrentObject.h"
|
#include "threads/beast_SharedData.h"
|
||||||
#include "threads/beast_ConcurrentState.h"
|
|
||||||
#include "threads/beast_GlobalThreadGroup.h"
|
#include "threads/beast_GlobalThreadGroup.h"
|
||||||
#include "threads/beast_Listeners.h"
|
#include "threads/beast_Listeners.h"
|
||||||
#include "threads/beast_ManualCallQueue.h"
|
#include "threads/beast_ManualCallQueue.h"
|
||||||
|
|||||||
@@ -313,11 +313,11 @@ public:
|
|||||||
|
|
||||||
struct SharedState; // contains data shared between threads
|
struct SharedState; // contains data shared between threads
|
||||||
|
|
||||||
ConcurrentState <SharedState> sharedState;
|
SharedData <SharedState> sharedState;
|
||||||
|
|
||||||
void stateChanged ()
|
void stateChanged ()
|
||||||
{
|
{
|
||||||
ConcurrentState <SharedState>::ReadAccess state (sharedState);
|
SharedData <SharedState>::ReadAccess state (sharedState);
|
||||||
|
|
||||||
// (read state)
|
// (read state)
|
||||||
}
|
}
|
||||||
@@ -326,7 +326,7 @@ public:
|
|||||||
|
|
||||||
void changeState ()
|
void changeState ()
|
||||||
{
|
{
|
||||||
ConcurrentState <State>::WriteAccess state (sharedState);
|
SharedData <State>::WriteAccess state (sharedState);
|
||||||
|
|
||||||
// (read and write state)
|
// (read and write state)
|
||||||
|
|
||||||
|
|||||||
@@ -137,7 +137,7 @@
|
|||||||
void addListener (Listener* listener, CallQueue& callQueue)
|
void addListener (Listener* listener, CallQueue& callQueue)
|
||||||
{
|
{
|
||||||
// Acquire read access to the shared state.
|
// Acquire read access to the shared state.
|
||||||
ConcurrentState <State>::ReadAccess state (m_state);
|
SharedData <State>::ReadAccess state (m_state);
|
||||||
|
|
||||||
// Add the listener.
|
// Add the listener.
|
||||||
m_listeners.add (listener, callQueue);
|
m_listeners.add (listener, callQueue);
|
||||||
@@ -171,7 +171,7 @@
|
|||||||
|
|
||||||
// Update shared state.
|
// Update shared state.
|
||||||
{
|
{
|
||||||
ConcurrentState <State>::WriteAccess state (m_state);
|
SharedData <State>::WriteAccess state (m_state);
|
||||||
|
|
||||||
m_state->outputLevel = newOutputLevel;
|
m_state->outputLevel = newOutputLevel;
|
||||||
}
|
}
|
||||||
@@ -188,7 +188,7 @@
|
|||||||
float outputLevel;
|
float outputLevel;
|
||||||
};
|
};
|
||||||
|
|
||||||
ConcurrentState <State> m_state;
|
SharedData <State> m_state;
|
||||||
|
|
||||||
ManualCallQueue m_fifo;
|
ManualCallQueue m_fifo;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
|
|
||||||
#ifndef BEAST_CONCURRENTSTATE_BEASTHEADER
|
#ifndef BEAST_SHAREDDATA_H_INCLUDED
|
||||||
#define BEAST_CONCURRENTSTATE_BEASTHEADER
|
#define BEAST_SHAREDDATA_H_INCLUDED
|
||||||
|
|
||||||
/*============================================================================*/
|
/*============================================================================*/
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
It also makes it easier to search for places in code which use unlocked
|
It also makes it easier to search for places in code which use unlocked
|
||||||
access.
|
access.
|
||||||
|
|
||||||
This code example demonstrates various forms of access to a ConcurrentState:
|
This code example demonstrates various forms of access to a SharedData:
|
||||||
|
|
||||||
@code
|
@code
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@
|
|||||||
String value2;
|
String value2;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef ConcurrentState <SharedData> SharedState;
|
typedef SharedData <SharedData> SharedState;
|
||||||
|
|
||||||
SharedState sharedState;
|
SharedState sharedState;
|
||||||
|
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Construct SharedData with one parameter
|
// Construct SharedData with one parameter
|
||||||
ConcurrentState <SharedData> sharedState (16);
|
SharedData <SharedData> sharedState (16);
|
||||||
|
|
||||||
@endcode
|
@endcode
|
||||||
|
|
||||||
@@ -112,11 +112,9 @@
|
|||||||
read access. Such an attempt will result in undefined behavior. Calling into
|
read access. Such an attempt will result in undefined behavior. Calling into
|
||||||
unknown code while holding a lock can cause deadlock. See
|
unknown code while holding a lock can cause deadlock. See
|
||||||
@ref CallQueue::queue().
|
@ref CallQueue::queue().
|
||||||
|
|
||||||
@ingroup beast_concurrent
|
|
||||||
*/
|
*/
|
||||||
template <class Object>
|
template <class Object>
|
||||||
class ConcurrentState : Uncopyable
|
class SharedData : Uncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
class ReadAccess;
|
class ReadAccess;
|
||||||
@@ -131,37 +129,37 @@ public:
|
|||||||
generated.
|
generated.
|
||||||
*/
|
*/
|
||||||
/** @{ */
|
/** @{ */
|
||||||
ConcurrentState () { }
|
SharedData () { }
|
||||||
|
|
||||||
template <class T1>
|
template <class T1>
|
||||||
explicit ConcurrentState (T1 t1)
|
explicit SharedData (T1 t1)
|
||||||
: m_obj (t1) { }
|
: m_obj (t1) { }
|
||||||
|
|
||||||
template <class T1, class T2>
|
template <class T1, class T2>
|
||||||
ConcurrentState (T1 t1, T2 t2)
|
SharedData (T1 t1, T2 t2)
|
||||||
: m_obj (t1, t2) { }
|
: m_obj (t1, t2) { }
|
||||||
|
|
||||||
template <class T1, class T2, class T3>
|
template <class T1, class T2, class T3>
|
||||||
ConcurrentState (T1 t1, T2 t2, T3 t3)
|
SharedData (T1 t1, T2 t2, T3 t3)
|
||||||
: m_obj (t1, t2, t3) { }
|
: m_obj (t1, t2, t3) { }
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4>
|
template <class T1, class T2, class T3, class T4>
|
||||||
ConcurrentState (T1 t1, T2 t2, T3 t3, T4 t4)
|
SharedData (T1 t1, T2 t2, T3 t3, T4 t4)
|
||||||
: m_obj (t1, t2, t3, t4) { }
|
: m_obj (t1, t2, t3, t4) { }
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4, class T5>
|
template <class T1, class T2, class T3, class T4, class T5>
|
||||||
ConcurrentState (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
SharedData (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5)
|
||||||
: m_obj (t1, t2, t3, t4, t5) { }
|
: m_obj (t1, t2, t3, t4, t5) { }
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
template <class T1, class T2, class T3, class T4, class T5, class T6>
|
||||||
ConcurrentState (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
SharedData (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6)
|
||||||
: m_obj (t1, t2, t3, t4, t5, t6) { }
|
: m_obj (t1, t2, t3, t4, t5, t6) { }
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7>
|
||||||
ConcurrentState (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : m_obj (t1, t2, t3, t4, t5, t6, t7) { }
|
SharedData (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7) : m_obj (t1, t2, t3, t4, t5, t6, t7) { }
|
||||||
|
|
||||||
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
template <class T1, class T2, class T3, class T4, class T5, class T6, class T7, class T8>
|
||||||
ConcurrentState (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
|
SharedData (T1 t1, T2 t2, T3 t3, T4 t4, T5 t5, T6 t6, T7 t7, T8 t8)
|
||||||
: m_obj (t1, t2, t3, t4, t5, t6, t7, t8) { }
|
: m_obj (t1, t2, t3, t4, t5, t6, t7, t8) { }
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
@@ -174,15 +172,15 @@ private:
|
|||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Unlocked access to a ConcurrentState.
|
/** Unlocked access to a SharedData.
|
||||||
|
|
||||||
Use sparingly.
|
Use sparingly.
|
||||||
*/
|
*/
|
||||||
template <class Object>
|
template <class Object>
|
||||||
class ConcurrentState <Object>::UnlockedAccess : Uncopyable
|
class SharedData <Object>::UnlockedAccess : Uncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit UnlockedAccess (ConcurrentState const& state)
|
explicit UnlockedAccess (SharedData const& state)
|
||||||
: m_state (state)
|
: m_state (state)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -201,19 +199,19 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConcurrentState const& m_state;
|
SharedData const& m_state;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Read only access to a ConcurrentState */
|
/** Read only access to a SharedData */
|
||||||
template <class Object>
|
template <class Object>
|
||||||
class ConcurrentState <Object>::ReadAccess : Uncopyable
|
class SharedData <Object>::ReadAccess : Uncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/** Create a ReadAccess from the specified ConcurrentState */
|
/** Create a ReadAccess from the specified SharedData */
|
||||||
explicit ReadAccess (ConcurrentState const volatile& state)
|
explicit ReadAccess (SharedData const volatile& state)
|
||||||
: m_state (const_cast <ConcurrentState const&> (state))
|
: m_state (const_cast <SharedData const&> (state))
|
||||||
, m_lock (m_state.m_mutex)
|
, m_lock (m_state.m_mutex)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -237,18 +235,18 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConcurrentState const& m_state;
|
SharedData const& m_state;
|
||||||
ReadWriteMutexType::ScopedReadLockType m_lock;
|
ReadWriteMutexType::ScopedReadLockType m_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
/** Read/write access to a ConcurrentState */
|
/** Read/write access to a SharedData */
|
||||||
template <class Object>
|
template <class Object>
|
||||||
class ConcurrentState <Object>::WriteAccess : Uncopyable
|
class SharedData <Object>::WriteAccess : Uncopyable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit WriteAccess (ConcurrentState& state)
|
explicit WriteAccess (SharedData& state)
|
||||||
: m_state (state)
|
: m_state (state)
|
||||||
, m_lock (m_state.m_mutex)
|
, m_lock (m_state.m_mutex)
|
||||||
{
|
{
|
||||||
@@ -291,7 +289,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ConcurrentState& m_state;
|
SharedData& m_state;
|
||||||
ReadWriteMutexType::ScopedWriteLockType m_lock;
|
ReadWriteMutexType::ScopedWriteLockType m_lock;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -45,7 +45,7 @@ public:
|
|||||||
method is called. If manualReset is true, then once the event is signalled,
|
method is called. If manualReset is true, then once the event is signalled,
|
||||||
the only way to reset it will be by calling the reset() method.
|
the only way to reset it will be by calling the reset() method.
|
||||||
*/
|
*/
|
||||||
WaitableEvent (bool manualReset = false) noexcept;
|
explicit WaitableEvent (bool manualReset = false) noexcept;
|
||||||
|
|
||||||
/** Destructor.
|
/** Destructor.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user