Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions include/xrpl/basics/TaggedCache.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <xrpl/basics/IntrusivePointer.ipp>
#include <xrpl/basics/TaggedCache.h>
#include <xrpl/basics/scope.h>

namespace xrpl {

Expand Down Expand Up @@ -536,8 +537,15 @@ TaggedCache<Key, T, IsKeyCache, SharedWeakUnionPointer, SharedPointerType, Hash,
std::vector<key_type> v;

{
std::scoped_lock const lock(mutex_);
v.reserve(cache_.size());
std::unique_lock lock(mutex_);
for (int size = cache_.size(); v.capacity() < size; size = cache_.size())
Comment thread
ximinez marked this conversation as resolved.
Outdated
{
ScopeUnlock const unlock(lock);
v.reserve(size);
}
XRPL_ASSERT(lock.owns_lock(), "xrpl::TaggedCache::getKeys(): owns lock");
XRPL_ASSERT(
v.capacity() >= cache_.size(), "xrpl::TaggedCache::getKeys(): sufficient capacity");
for (auto const& _ : cache_)
v.push_back(_.first);
}
Expand Down
Loading