Remove ConcurrentObject and rename to SharedData

This commit is contained in:
Vinnie Falco
2013-06-30 09:55:18 -07:00
parent 02f137ace8
commit 2fefe6ca8d
12 changed files with 48 additions and 65 deletions

View File

@@ -67,7 +67,7 @@
specific classes.
*/
#ifndef BEAST_CHECK_MEMORY_LEAKS
//#define BEAST_CHECK_MEMORY_LEAKS 0
//#define BEAST_CHECK_MEMORY_LEAKS 1
#endif
//------------------------------------------------------------------------------

View File

@@ -78,8 +78,7 @@
<ClInclude Include="..\..\modules\beast_basics\memory\beast_GlobalPagedFreeStore.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_ConcurrentObject.h" />
<ClInclude Include="..\..\modules\beast_basics\threads\beast_ConcurrentState.h" />
<ClInclude Include="..\..\modules\beast_basics\threads\beast_SharedData.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_Listeners.h" />
@@ -280,12 +279,6 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
</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">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>

View File

@@ -503,12 +503,6 @@
<ClInclude Include="..\..\modules\beast_basics\threads\beast_CallQueue.h">
<Filter>beast_basics\threads</Filter>
</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">
<Filter>beast_basics\threads</Filter>
</ClInclude>
@@ -611,6 +605,9 @@
<ClInclude Include="..\..\modules\beast_core\time\beast_PerformedAtExit.h">
<Filter>beast_core\time</Filter>
</ClInclude>
<ClInclude Include="..\..\modules\beast_basics\threads\beast_SharedData.h">
<Filter>beast_basics\threads</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\modules\beast_core\beast_core.cpp">
@@ -889,9 +886,6 @@
<ClCompile Include="..\..\modules\beast_basics\threads\beast_CallQueue.cpp">
<Filter>beast_basics\threads</Filter>
</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">
<Filter>beast_basics\threads</Filter>
</ClCompile>

View File

@@ -34,7 +34,7 @@ BEAST TODO
- 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?

View File

@@ -53,7 +53,6 @@ namespace beast
#include "memory/beast_GlobalPagedFreeStore.cpp"
#include "memory/beast_PagedFreeStore.cpp"
#include "threads/beast_CallQueue.cpp"
#include "threads/beast_ConcurrentObject.cpp"
#include "threads/beast_Listeners.cpp"
#include "threads/beast_ManualCallQueue.cpp"
#include "threads/beast_ParallelFor.cpp"

View File

@@ -263,8 +263,7 @@ namespace beast
#include "threads/beast_ReadWriteMutex.h"
#include "threads/beast_ThreadGroup.h"
#include "threads/beast_CallQueue.h"
#include "threads/beast_ConcurrentObject.h"
#include "threads/beast_ConcurrentState.h"
#include "threads/beast_SharedData.h"
#include "threads/beast_GlobalThreadGroup.h"
#include "threads/beast_Listeners.h"
#include "threads/beast_ManualCallQueue.h"

View File

@@ -313,11 +313,11 @@ public:
struct SharedState; // contains data shared between threads
ConcurrentState <SharedState> sharedState;
SharedData <SharedState> sharedState;
void stateChanged ()
{
ConcurrentState <SharedState>::ReadAccess state (sharedState);
SharedData <SharedState>::ReadAccess state (sharedState);
// (read state)
}
@@ -326,7 +326,7 @@ public:
void changeState ()
{
ConcurrentState <State>::WriteAccess state (sharedState);
SharedData <State>::WriteAccess 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.
ConcurrentState <State>::ReadAccess state (m_state);
SharedData <State>::ReadAccess state (m_state);
// Add the listener.
m_listeners.add (listener, callQueue);
@@ -171,7 +171,7 @@
// Update shared state.
{
ConcurrentState <State>::WriteAccess state (m_state);
SharedData <State>::WriteAccess state (m_state);
m_state->outputLevel = newOutputLevel;
}
@@ -188,7 +188,7 @@
float outputLevel;
};
ConcurrentState <State> m_state;
SharedData <State> m_state;
ManualCallQueue m_fifo;
};

View File

@@ -17,8 +17,8 @@
*/
//==============================================================================
#ifndef BEAST_CONCURRENTSTATE_BEASTHEADER
#define BEAST_CONCURRENTSTATE_BEASTHEADER
#ifndef BEAST_SHAREDDATA_H_INCLUDED
#define BEAST_SHAREDDATA_H_INCLUDED
/*============================================================================*/
/**
@@ -52,7 +52,7 @@
It also makes it easier to search for places in code which use unlocked
access.
This code example demonstrates various forms of access to a ConcurrentState:
This code example demonstrates various forms of access to a SharedData:
@code
@@ -62,7 +62,7 @@
String value2;
};
typedef ConcurrentState <SharedData> SharedState;
typedef SharedData <SharedData> SharedState;
SharedState sharedState;
@@ -101,7 +101,7 @@
};
// Construct SharedData with one parameter
ConcurrentState <SharedData> sharedState (16);
SharedData <SharedData> sharedState (16);
@endcode
@@ -112,11 +112,9 @@
read access. Such an attempt will result in undefined behavior. Calling into
unknown code while holding a lock can cause deadlock. See
@ref CallQueue::queue().
@ingroup beast_concurrent
*/
template <class Object>
class ConcurrentState : Uncopyable
class SharedData : Uncopyable
{
public:
class ReadAccess;
@@ -131,37 +129,37 @@ public:
generated.
*/
/** @{ */
ConcurrentState () { }
SharedData () { }
template <class T1>
explicit ConcurrentState (T1 t1)
explicit SharedData (T1 t1)
: m_obj (t1) { }
template <class T1, class T2>
ConcurrentState (T1 t1, T2 t2)
SharedData (T1 t1, T2 t2)
: m_obj (t1, t2) { }
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) { }
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) { }
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) { }
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) { }
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>
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) { }
/** @} */
@@ -174,15 +172,15 @@ private:
//------------------------------------------------------------------------------
/** Unlocked access to a ConcurrentState.
/** Unlocked access to a SharedData.
Use sparingly.
*/
template <class Object>
class ConcurrentState <Object>::UnlockedAccess : Uncopyable
class SharedData <Object>::UnlockedAccess : Uncopyable
{
public:
explicit UnlockedAccess (ConcurrentState const& state)
explicit UnlockedAccess (SharedData const& state)
: m_state (state)
{
}
@@ -201,19 +199,19 @@ public:
}
private:
ConcurrentState const& m_state;
SharedData const& m_state;
};
//------------------------------------------------------------------------------
/** Read only access to a ConcurrentState */
/** Read only access to a SharedData */
template <class Object>
class ConcurrentState <Object>::ReadAccess : Uncopyable
class SharedData <Object>::ReadAccess : Uncopyable
{
public:
/** Create a ReadAccess from the specified ConcurrentState */
explicit ReadAccess (ConcurrentState const volatile& state)
: m_state (const_cast <ConcurrentState const&> (state))
/** Create a ReadAccess from the specified SharedData */
explicit ReadAccess (SharedData const volatile& state)
: m_state (const_cast <SharedData const&> (state))
, m_lock (m_state.m_mutex)
{
}
@@ -237,18 +235,18 @@ public:
}
private:
ConcurrentState const& m_state;
SharedData const& m_state;
ReadWriteMutexType::ScopedReadLockType m_lock;
};
//------------------------------------------------------------------------------
/** Read/write access to a ConcurrentState */
/** Read/write access to a SharedData */
template <class Object>
class ConcurrentState <Object>::WriteAccess : Uncopyable
class SharedData <Object>::WriteAccess : Uncopyable
{
public:
explicit WriteAccess (ConcurrentState& state)
explicit WriteAccess (SharedData& state)
: m_state (state)
, m_lock (m_state.m_mutex)
{
@@ -291,7 +289,7 @@ public:
}
private:
ConcurrentState& m_state;
SharedData& m_state;
ReadWriteMutexType::ScopedWriteLockType m_lock;
};

View File

@@ -45,7 +45,7 @@ public:
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.
*/
WaitableEvent (bool manualReset = false) noexcept;
explicit WaitableEvent (bool manualReset = false) noexcept;
/** Destructor.

View File

@@ -4,8 +4,8 @@
*/
//==============================================================================
#ifndef RIPPLE_IPEERS_H
#define RIPPLE_IPEERS_H
#ifndef RIPPLE_IPEERS_H_INCLUDED
#define RIPPLE_IPEERS_H_INCLUDED
/** Manages the set of connected peers.
*/

View File

@@ -133,14 +133,14 @@ int rippleMain (int argc, char** argv)
// At exit, reports all memory blocks which have not been freed.
//
#if 1
//Debug::setHeapReportLeaks (false);
Debug::setHeapReportLeaks (false);
#else
// This is some temporary leak checking test code
//
Debug::setHeapReportLeaks (true);
Debug::setHeapReportLeaks (false);
malloc (512); // Any leaks before this line in the output are from static initializations.
//malloc (512); // Any leaks before this line in the output are from static initializations.
ThreadWithCallQueue t ("test");
GlobalPagedFreeStore::getInstance ();