mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix attempt
This commit is contained in:
@@ -127,15 +127,16 @@ public:
|
||||
|
||||
@param key The key corresponding to the object
|
||||
@param data A shared pointer to the data corresponding to the object.
|
||||
@param replace Function that decides if cache should be replaced
|
||||
@param replaceCallback Function that decides if cache should be replaced
|
||||
|
||||
@return `true` If the key already existed.
|
||||
@return First item: `true` If the key already existed; Second item: The
|
||||
in the cache.
|
||||
*/
|
||||
template <class R>
|
||||
bool
|
||||
std::pair<bool, SharedPointerType>
|
||||
canonicalize(
|
||||
key_type const& key,
|
||||
SharedPointerType& data,
|
||||
SharedPointerType const& data,
|
||||
R&& replaceCallback);
|
||||
|
||||
bool
|
||||
|
||||
@@ -403,7 +403,7 @@ template <
|
||||
class KeyEqual,
|
||||
class Mutex>
|
||||
template <class R>
|
||||
inline bool
|
||||
inline std::pair<bool, SharedPointerType>
|
||||
TaggedCache<
|
||||
Key,
|
||||
T,
|
||||
@@ -415,7 +415,7 @@ TaggedCache<
|
||||
Mutex>::
|
||||
canonicalize(
|
||||
key_type const& key,
|
||||
SharedPointerType& data,
|
||||
SharedPointerType const& data,
|
||||
R&& replaceCallback)
|
||||
{
|
||||
// Return canonical value, store if needed, refresh in cache
|
||||
@@ -431,7 +431,7 @@ TaggedCache<
|
||||
std::forward_as_tuple(key),
|
||||
std::forward_as_tuple(m_clock.now(), data));
|
||||
++m_cache_count;
|
||||
return false;
|
||||
return std::make_pair(false, data);
|
||||
}
|
||||
|
||||
Entry& entry = cit->second;
|
||||
@@ -457,12 +457,7 @@ TaggedCache<
|
||||
{
|
||||
entry.ptr = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
data = entry.ptr.getStrong();
|
||||
}
|
||||
|
||||
return true;
|
||||
return std::make_pair(true, entry.ptr.getStrong());
|
||||
}
|
||||
|
||||
auto cachedData = entry.lock();
|
||||
@@ -473,20 +468,14 @@ TaggedCache<
|
||||
{
|
||||
entry.ptr = data;
|
||||
}
|
||||
else
|
||||
{
|
||||
entry.ptr.convertToStrong();
|
||||
data = cachedData;
|
||||
}
|
||||
|
||||
entry.ptr.convertToStrong();
|
||||
++m_cache_count;
|
||||
return true;
|
||||
return std::make_pair(true, entry.ptr.getStrong());
|
||||
}
|
||||
|
||||
entry.ptr = data;
|
||||
++m_cache_count;
|
||||
|
||||
return false;
|
||||
return std::make_pair(false, data);
|
||||
}
|
||||
|
||||
template <
|
||||
@@ -512,8 +501,9 @@ TaggedCache<
|
||||
key_type const& key,
|
||||
SharedPointerType const& data)
|
||||
{
|
||||
return canonicalize(
|
||||
key, const_cast<SharedPointerType&>(data), []() { return true; });
|
||||
auto [alreadyExists, _] = canonicalize(
|
||||
key, data, []() { return true; });
|
||||
return alreadyExists;
|
||||
}
|
||||
|
||||
template <
|
||||
@@ -537,7 +527,9 @@ TaggedCache<
|
||||
Mutex>::
|
||||
canonicalize_replace_client(key_type const& key, SharedPointerType& data)
|
||||
{
|
||||
return canonicalize(key, data, []() { return false; });
|
||||
auto [alreadyExists, itemInCache] = canonicalize(key, data, []() { return false; });
|
||||
data = itemInCache;
|
||||
return alreadyExists;
|
||||
}
|
||||
|
||||
template <
|
||||
|
||||
Reference in New Issue
Block a user