Remove unused SyncUnorderedMap

This commit is contained in:
Howard Hinnant
2015-03-05 12:58:00 -05:00
committed by Tom Ritchford
parent 2e59378ab7
commit 4611d5a35f
5 changed files with 16 additions and 195 deletions

View File

@@ -1955,10 +1955,6 @@
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\tx\TransactionMeta.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\websocket\WSConnection.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\basics\base_uint.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\BasicConfig.h">
@@ -2063,8 +2059,6 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\Sustain.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\SyncUnorderedMap.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\TaggedCache.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\TestSuite.h">
@@ -2268,17 +2262,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\impl\Object.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\impl\Output.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\impl\to_string.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\impl\Writer.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\json\JsonPropertyStream.h">
</ClInclude>
@@ -2299,13 +2296,16 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\tests\Object.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\tests\Output.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\ripple\json\tests\Writer.test.cpp">
<ExcludedFromBuild>True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\json\to_string.h">
</ClInclude>
@@ -3461,7 +3461,9 @@
<ClCompile Include="..\..\src\ripple\unity\websocket02.cpp">
</ClCompile>
<ClCompile Include="..\..\src\ripple\unity\websocket04.cpp">
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug.classic|x64'">..\..\src\websocketpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='debug|x64'">..\..\src\websocketpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release.classic|x64'">..\..\src\websocketpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='release|x64'">..\..\src\websocketpp;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
</ClCompile>
<ClInclude Include="..\..\src\ripple\validators\Connection.h">

View File

@@ -319,9 +319,6 @@
<Filter Include="ripple\app\tx">
<UniqueIdentifier>{50FDCDC1-EC9C-9F3B-34C9-EF4137E132B4}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\app\websocket">
<UniqueIdentifier>{CE578C3A-4F3A-7E66-FFC5-0C94982FB975}</UniqueIdentifier>
</Filter>
<Filter Include="ripple\basics">
<UniqueIdentifier>{B8720E2F-21B1-2847-F96C-4E00A45DC639}</UniqueIdentifier>
</Filter>
@@ -2700,9 +2697,6 @@
<ClInclude Include="..\..\src\ripple\app\tx\TransactionMeta.h">
<Filter>ripple\app\tx</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\websocket\WSConnection.cpp">
<Filter>ripple\app\websocket</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\basics\base_uint.h">
<Filter>ripple\basics</Filter>
</ClInclude>
@@ -2817,9 +2811,6 @@
<ClInclude Include="..\..\src\ripple\basics\Sustain.h">
<Filter>ripple\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\SyncUnorderedMap.h">
<Filter>ripple\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\TaggedCache.h">
<Filter>ripple\basics</Filter>
</ClInclude>

View File

@@ -24,7 +24,6 @@
#include <beast/module/core/time/Time.h>
#include <beast/module/core/diagnostic/MeasureFunctionCallTime.h>
#include <beast/utility/Debug.h>
#include <ripple/basics/SyncUnorderedMap.h>
namespace ripple {
@@ -58,17 +57,6 @@ struct Destroyer <std::unordered_map <Key, Value, Hash, Alloc> >
}
};
/** Specialization for SyncUnorderedMapType
*/
template <typename Key, typename Value, typename Hash>
struct Destroyer <SyncUnorderedMapType <Key, Value, Hash> >
{
static void destroy (SyncUnorderedMapType <Key, Value, Hash>& v)
{
v.clear ();
}
};
/** Cleans up an elaspsed time so it prints nicely */
inline double cleanElapsed (double seconds) noexcept
{

View File

@@ -1,162 +0,0 @@
//------------------------------------------------------------------------------
/*
This file is part of rippled: https://github.com/ripple/rippled
Copyright (c) 2012, 2013 Ripple Labs Inc.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
//==============================================================================
#ifndef RIPPLE_BASICS_SYNCUNORDEREDMAP_H_INCLUDED
#define RIPPLE_BASICS_SYNCUNORDEREDMAP_H_INCLUDED
#include <ripple/basics/UnorderedContainers.h>
#include <mutex>
namespace ripple {
// Common base
class SyncUnorderedMap
{
public:
typedef std::recursive_mutex LockType;
typedef std::lock_guard <LockType> ScopedLockType;
};
/** This is a synchronized unordered map.
It is useful for cases where an unordered map contains all
or a subset of an unchanging data set.
*/
template <typename c_Key, typename c_Data, typename c_Hash = beast::uhash<>>
class SyncUnorderedMapType : public SyncUnorderedMap
{
public:
typedef c_Key key_type;
typedef c_Data data_type;
typedef hash_map<c_Key, c_Data, c_Hash> map_type;
class iterator
{
public:
bool operator== (const iterator& i) { return it == i.it; }
bool operator!= (const iterator& i) { return it != i.it; }
key_type const& key () { return it.first; }
data_type& data () { return it.second; }
protected:
typename map_type::iterator it;
};
public:
typedef SyncUnorderedMap::LockType LockType;
typedef SyncUnorderedMap::ScopedLockType ScopedLockType;
SyncUnorderedMapType (const SyncUnorderedMapType& m)
{
ScopedLockType sl (m.mLock);
mMap = m.mMap;
}
SyncUnorderedMapType ()
{ ; }
// Operations that are not inherently synchronous safe
// (Usually because they can change the contents of the map or
// invalidated its members.)
void operator= (const SyncUnorderedMapType& m)
{
ScopedLockType sl (m.mLock);
mMap = m.mMap;
}
void clear ()
{
mMap.clear();
}
int erase (key_type const& key)
{
return mMap.erase (key);
}
void erase (iterator& iterator)
{
mMap.erase (iterator.it);
}
void replace (key_type const& key, data_type const& data)
{
mMap[key] = data;
}
void rehash (int s)
{
mMap.rehash (s);
}
map_type& peekMap ()
{
return mMap;
}
// Operations that are inherently synchronous safe
std::size_t size () const
{
ScopedLockType sl (mLock);
return mMap.size ();
}
// If the value is already in the map, replace it with the old value
// Otherwise, store the value passed.
// Returns 'true' if the value was added to the map
bool canonicalize (key_type const& key, data_type* value)
{
ScopedLockType sl (mLock);
auto it = mMap.emplace (key, *value);
if (!it.second) // Value was not added, take existing value
*value = it.first->second;
return it.second;
}
// Retrieve the existing value from the map.
// If none, return an 'empty' value
data_type retrieve (key_type const& key)
{
data_type ret;
{
ScopedLockType sl (mLock);
auto it = mMap.find (key);
if (it != mMap.end ())
ret = it->second;
}
return ret;
}
private:
map_type mMap;
mutable LockType mLock;
};
} // ripple
#endif

View File

@@ -72,6 +72,8 @@ be modified must be copied before they are placed in the mutable map.
## SHAMap Thread Safety ##
*This description is obsolete and needs to be rewritten.*
SHAMaps can be thread safe, depending on how they are used. The SHAMap
uses a SyncUnorderedMap for its storage. The SyncUnorderedMap has three
thread-safe methods: