Use standard C++ types instead of type aliases:

* Remove ripple::RippleMutex and ripple::RippleRecursiveMutex
  and use std::mutex and std::recursive_mutex respectively.
* Use std::lock_guard instead of std::unique_lock when the
  additional features of std::unique_lock are not needed.
This commit is contained in:
Nik Bougalis
2015-09-29 15:07:03 -07:00
committed by Vinnie Falco
parent 333ba69d60
commit f424ae6942
25 changed files with 100 additions and 158 deletions

View File

@@ -1877,8 +1877,6 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\BasicConfig.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\BasicTypes.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\Blob.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\Buffer.h">

View File

@@ -2616,9 +2616,6 @@
<ClInclude Include="..\..\src\ripple\basics\BasicConfig.h">
<Filter>ripple\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\BasicTypes.h">
<Filter>ripple\basics</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\basics\Blob.h">
<Filter>ripple\basics</Filter>
</ClInclude>

View File

@@ -26,13 +26,13 @@ namespace ripple {
void BookListeners::addSubscriber (InfoSub::ref sub)
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
mListeners[sub->getSeq ()] = sub;
}
void BookListeners::removeSubscriber (std::uint64_t seq)
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
mListeners.erase (seq);
}
@@ -40,7 +40,7 @@ void BookListeners::publish (Json::Value const& jvObj)
{
std::string sObj = to_string (jvObj);
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
auto it = mListeners.cbegin ();
while (it != mListeners.cend ())

View File

@@ -22,6 +22,7 @@
#include <ripple/net/InfoSub.h>
#include <memory>
#include <mutex>
namespace ripple {
@@ -38,9 +39,7 @@ public:
void publish (Json::Value const& jvObj);
private:
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
std::recursive_mutex mLock;
hash_map<std::uint64_t, InfoSub::wptr> mListeners;
};

View File

@@ -24,6 +24,7 @@
#include <ripple/app/ledger/Ledger.h>
#include <ripple/overlay/PeerSet.h>
#include <ripple/basics/CountedObject.h>
#include <mutex>
#include <set>
namespace ripple {
@@ -160,7 +161,7 @@ private:
std::set <uint256> mRecentNodes;
// Data we have received from peers
PeerSet::LockType mReceivedDataLock;
std::recursive_mutex mReceivedDataLock;
std::vector <PeerDataPairType> mReceivedData;
bool mReceiveDispatched;

View File

@@ -20,6 +20,8 @@
#ifndef RIPPLE_APP_LEDGER_LEDGERHOLDER_H_INCLUDED
#define RIPPLE_APP_LEDGER_LEDGERHOLDER_H_INCLUDED
#include <mutex>
namespace ripple {
// Can std::atomic<std::shared_ptr>> make this lock free?
@@ -29,9 +31,6 @@ namespace ripple {
class LedgerHolder
{
public:
using LockType = RippleMutex;
using ScopedLockType = std::lock_guard <LockType>;
// Update the held ledger
void set (Ledger::pointer ledger)
{
@@ -40,8 +39,7 @@ public:
ledger = std::make_shared <Ledger> (*ledger, false);
{
ScopedLockType sl (m_lock);
std::lock_guard <std::mutex> sl (m_lock);
m_heldLedger = ledger;
}
}
@@ -49,8 +47,7 @@ public:
// Return the (immutable) held ledger
Ledger::pointer get ()
{
ScopedLockType sl (m_lock);
std::lock_guard <std::mutex> sl (m_lock);
return m_heldLedger;
}
@@ -61,19 +58,15 @@ public:
return ret ? std::make_shared <Ledger> (*ret, true) : ret;
}
bool empty ()
{
ScopedLockType sl (m_lock);
std::lock_guard <std::mutex> sl (m_lock);
return m_heldLedger == nullptr;
}
private:
LockType m_lock;
std::mutex m_lock;
Ledger::pointer m_heldLedger;
};
} // ripple

View File

@@ -31,6 +31,7 @@
#include <beast/threads/Stoppable.h>
#include <beast/threads/UnlockGuard.h>
#include <beast/utility/PropertyStream.h>
#include <mutex>
#include "ripple.pb.h"
@@ -63,10 +64,6 @@ public:
using callback = std::function <void (Ledger::ref)>;
public:
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::unique_lock <LockType>;
using ScopedUnlockType = beast::GenericScopedUnlock <LockType>;
virtual ~LedgerMaster () = default;
virtual LedgerIndex getCurrentLedgerIndex () = 0;
@@ -75,7 +72,7 @@ public:
virtual bool isCompatible (Ledger::pointer,
beast::Journal::Stream, const char* reason) = 0;
virtual LockType& peekMutex () = 0;
virtual std::recursive_mutex& peekMutex () = 0;
// The current ledger is the ledger we believe new transactions should go in
virtual std::shared_ptr<ReadView const> getCurrentLedger () = 0;

View File

@@ -38,7 +38,7 @@ OrderBookDB::OrderBookDB (Application& app, Stoppable& parent)
void OrderBookDB::invalidate ()
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
mSeq = 0;
}
@@ -46,7 +46,7 @@ void OrderBookDB::setup(
std::shared_ptr<ReadView const> const& ledger)
{
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
auto seq = ledger->info().seq;
// Do a full update every 256 ledgers
@@ -122,7 +122,7 @@ void OrderBookDB::update(
{
JLOG (j_.info)
<< "OrderBookDB::update encountered a missing node";
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
mSeq = 0;
return;
}
@@ -130,7 +130,7 @@ void OrderBookDB::update(
JLOG (j_.debug)
<< "OrderBookDB::update< " << books << " books found";
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
mXRPBooks.swap(XRPBooks);
mSourceMap.swap(sourceMap);
@@ -142,7 +142,7 @@ void OrderBookDB::update(
void OrderBookDB::addOrderBook(Book const& book)
{
bool toXRP = isXRP (book.out);
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
if (toXRP)
{
@@ -177,26 +177,26 @@ void OrderBookDB::addOrderBook(Book const& book)
// return list of all orderbooks that want this issuerID and currencyID
OrderBook::List OrderBookDB::getBooksByTakerPays (Issue const& issue)
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
auto it = mSourceMap.find (issue);
return it == mSourceMap.end () ? OrderBook::List() : it->second;
}
int OrderBookDB::getBookSize(Issue const& issue) {
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
auto it = mSourceMap.find (issue);
return it == mSourceMap.end () ? 0 : it->second.size();
}
bool OrderBookDB::isBookToXRP(Issue const& issue)
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
return mXRPBooks.count(issue) > 0;
}
BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book)
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
auto ret = getBookListeners (book);
if (!ret)
@@ -213,7 +213,7 @@ BookListeners::pointer OrderBookDB::makeBookListeners (Book const& book)
BookListeners::pointer OrderBookDB::getBookListeners (Book const& book)
{
BookListeners::pointer ret;
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
auto it0 = mListeners.find (book);
if (it0 != mListeners.end ())
@@ -228,7 +228,7 @@ void OrderBookDB::processTxn (
std::shared_ptr<ReadView const> const& ledger,
const AcceptedLedgerTx& alTx, Json::Value const& jvObj)
{
ScopedLockType sl (mLock);
std::lock_guard <std::recursive_mutex> sl (mLock);
if (alTx.getResult () == tesSUCCESS)
{

View File

@@ -24,6 +24,7 @@
#include <ripple/app/ledger/BookListeners.h>
#include <ripple/app/main/Application.h>
#include <ripple/app/misc/OrderBook.h>
#include <mutex>
namespace ripple {
@@ -73,9 +74,7 @@ private:
// does an order book to XRP exist
hash_set <Issue> mXRPBooks;
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
std::recursive_mutex mLock;
using BookToListenersMap = hash_map <Book, BookListeners::pointer>;

View File

@@ -29,6 +29,7 @@
#include <beast/cxx14/memory.h> // <memory>
#include <beast/module/core/text/LexicalCast.h>
#include <beast/container/aged_map.h>
#include <mutex>
namespace ripple {
@@ -415,13 +416,12 @@ public:
private:
clock_type& m_clock;
using ScopedLockType = std::unique_lock <std::recursive_mutex>;
std::recursive_mutex mLock;
using MapType = hash_map <uint256, InboundLedger::pointer>;
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::unique_lock <LockType>;
LockType mLock;
MapType mLedgers;
beast::aged_map <uint256, std::uint32_t> mRecentFailures;
beast::insight::Counter mCounter;

View File

@@ -1178,10 +1178,9 @@ void LedgerConsensusImp::accept (std::shared_ptr<SHAMap> set)
{
// Build new open ledger
auto lock = beast::make_lock(
app_.getMasterMutex(), std::defer_lock);
LedgerMaster::ScopedLockType sl (
auto sl = beast::make_lock(
ledgerMaster_.peekMutex (), std::defer_lock);
std::lock(lock, sl);

View File

@@ -65,14 +65,13 @@ class LedgerMasterImp
: public LedgerMaster
{
public:
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::lock_guard <LockType>;
using ScopedUnlockType = beast::GenericScopedUnlock <LockType>;
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
using ScopedUnlockType = beast::GenericScopedUnlock <std::recursive_mutex>;
Application& app_;
beast::Journal m_journal;
LockType m_mutex;
std::recursive_mutex m_mutex;
// The ledger that most recently closed.
LedgerHolder mClosedLedger;
@@ -99,7 +98,7 @@ public:
// A set of transactions to replay during the next close
std::unique_ptr<LedgerReplay> replayData;
LockType mCompleteLock;
std::recursive_mutex mCompleteLock;
RangeSet mCompleteLedgers;
std::unique_ptr <LedgerCleaner> mLedgerCleaner;
@@ -1289,7 +1288,7 @@ public:
}
}
LockType& peekMutex () override
std::recursive_mutex& peekMutex () override
{
return m_mutex;
}

View File

@@ -28,6 +28,7 @@
#include <boost/format.hpp>
#include <boost/tokenizer.hpp>
#include <algorithm>
#include <mutex>
namespace ripple {
/** Track the list of "amendments"
@@ -43,9 +44,7 @@ protected:
using amendmentMap_t = hash_map<uint256, AmendmentState>;
using amendmentList_t = hash_set<uint256>;
using LockType = RippleMutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
std::mutex mLock;
amendmentMap_t m_amendmentMap;
std::uint32_t m_lastUpdateSeq;
@@ -213,7 +212,7 @@ AmendmentTableImpl::getExisting (uint256 const& amendmentHash)
uint256
AmendmentTableImpl::get (std::string const& name)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto const& e : m_amendmentMap)
{
@@ -237,7 +236,7 @@ AmendmentTableImpl::addKnown (AmendmentName const& name)
throw std::runtime_error (errorMsg);
}
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState& amendment = getCreate (name.id ());
if (!name.friendlyName ().empty ())
@@ -250,7 +249,7 @@ AmendmentTableImpl::addKnown (AmendmentName const& name)
bool
AmendmentTableImpl::veto (uint256 const& amendment)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState& s = getCreate (amendment);
if (s.mVetoed)
@@ -263,7 +262,7 @@ AmendmentTableImpl::veto (uint256 const& amendment)
bool
AmendmentTableImpl::unVeto (uint256 const& amendment)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState* s = getExisting (amendment);
if (!s || !s->mVetoed)
@@ -276,7 +275,7 @@ AmendmentTableImpl::unVeto (uint256 const& amendment)
bool
AmendmentTableImpl::enable (uint256 const& amendment)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState& s = getCreate (amendment);
if (s.mEnabled)
@@ -289,7 +288,7 @@ AmendmentTableImpl::enable (uint256 const& amendment)
bool
AmendmentTableImpl::disable (uint256 const& amendment)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState* s = getExisting (amendment);
if (!s || !s->mEnabled)
@@ -302,7 +301,7 @@ AmendmentTableImpl::disable (uint256 const& amendment)
bool
AmendmentTableImpl::isEnabled (uint256 const& amendment)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState* s = getExisting (amendment);
return s && s->mEnabled;
}
@@ -310,7 +309,7 @@ AmendmentTableImpl::isEnabled (uint256 const& amendment)
bool
AmendmentTableImpl::isSupported (uint256 const& amendment)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
AmendmentState* s = getExisting (amendment);
return s && s->mSupported;
}
@@ -319,7 +318,7 @@ AmendmentTableImpl::amendmentList_t
AmendmentTableImpl::getVetoed ()
{
amendmentList_t ret;
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto const& e : m_amendmentMap)
{
if (e.second.mVetoed)
@@ -332,7 +331,7 @@ AmendmentTableImpl::amendmentList_t
AmendmentTableImpl::getEnabled ()
{
amendmentList_t ret;
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto const& e : m_amendmentMap)
{
if (e.second.mEnabled)
@@ -345,7 +344,7 @@ AmendmentTableImpl::amendmentList_t
AmendmentTableImpl::getDesired (enabledAmendments_t const& enabled)
{
amendmentList_t ret;
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto const& e : m_amendmentMap)
{
@@ -360,7 +359,7 @@ AmendmentTableImpl::getDesired (enabledAmendments_t const& enabled)
void
AmendmentTableImpl::setEnabled (const std::vector<uint256>& amendments)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto& e : m_amendmentMap)
{
e.second.mEnabled = false;
@@ -374,7 +373,7 @@ AmendmentTableImpl::setEnabled (const std::vector<uint256>& amendments)
void
AmendmentTableImpl::setSupported (const std::vector<uint256>& amendments)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto &e : m_amendmentMap)
{
e.second.mSupported = false;
@@ -443,7 +442,7 @@ AmendmentTableImpl::doVoting (
std::map <uint256, std::uint32_t> actions;
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
// process all amendments we know of
for (auto const& entry : m_amendmentMap)
@@ -486,7 +485,7 @@ AmendmentTableImpl::doVoting (
bool
AmendmentTableImpl::needValidatedLedger (LedgerIndex ledgerSeq)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
// Is there a ledger in which an amendment could have been enabled
// between these two ledger sequences?
@@ -498,7 +497,7 @@ void
AmendmentTableImpl::doValidatedLedger (LedgerIndex ledgerSeq,
enabledAmendments_t enabled)
{
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
for (auto& e : m_amendmentMap)
e.second.mEnabled = (enabled.count (e.first) != 0);
@@ -509,7 +508,7 @@ AmendmentTableImpl::getJson (int)
{
Json::Value ret(Json::objectValue);
{
ScopedLockType sl(mLock);
std::lock_guard <std::mutex> sl(mLock);
for (auto const& e : m_amendmentMap)
{
setJson (ret[to_string (e.first)] = Json::objectValue, e.second);
@@ -536,7 +535,7 @@ AmendmentTableImpl::getJson (uint256 const& amendmentID)
Json::Value& jAmendment = (ret[to_string (amendmentID)] = Json::objectValue);
{
ScopedLockType sl(mLock);
std::lock_guard <std::mutex> sl(mLock);
AmendmentState& amendmentState = getCreate (amendmentID);
setJson (jAmendment, amendmentState);

View File

@@ -70,6 +70,7 @@
#include <boost/optional.hpp>
#include <tuple>
#include <condition_variable>
#include <mutex>
namespace ripple {
@@ -426,8 +427,7 @@ private:
using subRpcMapType = hash_map<std::string, InfoSub::pointer>;
// XXX Split into more locks.
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::lock_guard <LockType>;
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
Application& app_;
clock_type& m_clock;
@@ -435,7 +435,7 @@ private:
std::unique_ptr <LocalTxs> m_localTX;
LockType mSubLock;
std::recursive_mutex mSubLock;
std::atomic<OperatingMode> mMode;

View File

@@ -43,6 +43,7 @@
#include <boost/regex.hpp>
#include <boost/optional.hpp>
#include <fstream>
#include <mutex>
namespace ripple {
@@ -205,13 +206,8 @@ private:
private:
Application& app_;
typedef RippleMutex FetchLockType;
typedef std::lock_guard <FetchLockType> ScopedFetchLockType;
FetchLockType mFetchLock;
typedef RippleRecursiveMutex UNLLockType;
typedef std::lock_guard <UNLLockType> ScopedUNLLockType;
UNLLockType mUNLLock;
std::mutex mFetchLock;
std::recursive_mutex mUNLLock;
// VFALCO TODO Replace ptime with beast::Time
// Misc persistent information
@@ -485,14 +481,14 @@ void UniqueNodeListImp::start()
void UniqueNodeListImp::insertEphemeralKey (PublicKey pk, std::string comment)
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
ephemeralValidatorKeys_.insert (std::make_pair(std::move(pk), std::move(comment)));
}
void UniqueNodeListImp::deleteEphemeralKey (PublicKey const& pk)
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
ephemeralValidatorKeys_.erase (pk);
}
@@ -596,7 +592,7 @@ void UniqueNodeListImp::nodeRemovePublic (RippleAddress const& naNodePublic)
// YYY Only dirty on successful delete.
fetchDirty ();
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
mUNL.erase (naNodePublic.humanNodePublic ());
}
@@ -646,7 +642,7 @@ bool UniqueNodeListImp::nodeInUNL (RippleAddress const& naNodePublic)
auto const& blob = naNodePublic.getNodePublic();
PublicKey const pk (Slice(blob.data(), blob.size()));
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
if (ephemeralValidatorKeys_.find (pk) != ephemeralValidatorKeys_.end())
{
@@ -660,7 +656,7 @@ bool UniqueNodeListImp::nodeInUNL (RippleAddress const& naNodePublic)
bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic)
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
return m_clusterNodes.end () != m_clusterNodes.find (naNodePublic);
}
@@ -668,7 +664,7 @@ bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic)
bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic, std::string& name)
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
std::map<RippleAddress, ClusterNodeStatus>::iterator it = m_clusterNodes.find (naNodePublic);
if (it == m_clusterNodes.end ())
@@ -682,7 +678,7 @@ bool UniqueNodeListImp::nodeInCluster (RippleAddress const& naNodePublic, std::s
bool UniqueNodeListImp::nodeUpdate (RippleAddress const& naNodePublic, ClusterNodeStatus const& cnsStatus)
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
return m_clusterNodes[naNodePublic].update(cnsStatus);
}
@@ -693,7 +689,7 @@ UniqueNodeListImp::getClusterStatus()
{
std::map<RippleAddress, ClusterNodeStatus> ret;
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
ret = m_clusterNodes;
}
return ret;
@@ -707,7 +703,7 @@ std::uint32_t UniqueNodeListImp::getClusterFee()
std::vector<std::uint32_t> fees;
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
{
for (std::map<RippleAddress, ClusterNodeStatus>::iterator it = m_clusterNodes.begin(),
end = m_clusterNodes.end(); it != end; ++it)
@@ -728,7 +724,7 @@ std::uint32_t UniqueNodeListImp::getClusterFee()
void UniqueNodeListImp::addClusterStatus (Json::Value& obj)
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
if (m_clusterNodes.size() > 1) // nodes other than us
{
auto const now = app_.timeKeeper().now().time_since_epoch().count();
@@ -925,7 +921,7 @@ Json::Value UniqueNodeListImp::getUnlJson()
ret.append (node);
}
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
for (auto const& key : ephemeralValidatorKeys_)
{
@@ -1038,7 +1034,7 @@ void UniqueNodeListImp::trustedLoad()
}
auto db = app_.getWalletDB ().checkoutDb ();
ScopedUNLLockType slUNL (mUNLLock);
std::lock_guard <std::recursive_mutex> slUNL (mUNLLock);
mUNL.clear ();
@@ -1414,7 +1410,7 @@ void UniqueNodeListImp::scoreCompute()
}
{
ScopedUNLLockType sl (mUNLLock);
std::lock_guard <std::recursive_mutex> sl (mUNLLock);
// XXX Should limit to scores above a certain minimum and limit to a certain number.
mUNL.swap (usUNL);
@@ -1647,7 +1643,7 @@ void UniqueNodeListImp::fetchNext()
bool bFull;
{
ScopedFetchLockType sl (mFetchLock);
std::lock_guard <std::mutex> sl (mFetchLock);
bFull = (mFetchActive == NODE_FETCH_JOBS);
}
@@ -1685,7 +1681,7 @@ void UniqueNodeListImp::fetchNext()
if (!strDomain.empty ())
{
ScopedFetchLockType sl (mFetchLock);
std::lock_guard <std::mutex> sl (mFetchLock);
bFull = (mFetchActive == NODE_FETCH_JOBS);
@@ -1761,7 +1757,7 @@ void UniqueNodeListImp::fetchDirty()
void UniqueNodeListImp::fetchFinish()
{
{
ScopedFetchLockType sl (mFetchLock);
std::lock_guard <std::mutex> sl (mFetchLock);
mFetchActive--;
}

View File

@@ -28,6 +28,7 @@
#include <ripple/protocol/types.h>
#include <boost/optional.hpp>
#include <map>
#include <mutex>
#include <set>
namespace ripple {
@@ -91,6 +92,8 @@ public:
bool hasCompletion ();
private:
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
bool isValid (RippleLineCache::ref crCache);
void setValid ();
void resetLevel (int level);
@@ -105,9 +108,7 @@ private:
Application& app_;
beast::Journal m_journal;
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
std::recursive_mutex mLock;
PathRequests& mOwner;
@@ -128,7 +129,7 @@ private:
bool convert_all_;
LockType mIndexLock;
std::recursive_mutex mIndexLock;
LedgerIndex mLastIndex;
bool mInProgress;

View File

@@ -25,13 +25,14 @@
#include <ripple/app/paths/RippleLineCache.h>
#include <ripple/core/Job.h>
#include <atomic>
#include <mutex>
namespace ripple {
class PathRequests
{
public:
PathRequests (Application& app,
PathRequests (Application& app,
beast::Journal journal, beast::insight::Collector::ptr const& collector)
: app_ (app)
, mJournal (journal)
@@ -85,9 +86,8 @@ private:
std::atomic<int> mLastIdentifier;
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
std::recursive_mutex mLock;
};

View File

@@ -37,7 +37,7 @@ RippleLineCache::getRippleLines (AccountID const& accountID)
{
AccountKey key (accountID, hasher_ (accountID));
ScopedLockType sl (mLock);
std::lock_guard <std::mutex> sl (mLock);
auto it = mRLMap.emplace (key, RippleStateVector ());

View File

@@ -25,6 +25,7 @@
#include <ripple/basics/hardened_hash.h>
#include <cstddef>
#include <memory>
#include <mutex>
#include <vector>
namespace ripple {
@@ -49,9 +50,7 @@ public:
getRippleLines (AccountID const& accountID);
private:
using LockType = RippleMutex;
using ScopedLockType = std::lock_guard <LockType>;
LockType mLock;
std::mutex mLock;
ripple::hardened_hash<> hasher_;
std::shared_ptr <ReadView const> mLedger;

View File

@@ -28,6 +28,7 @@
#include <ripple/protocol/RippleLedgerHash.h>
#include <ripple/resource/Fees.h>
#include <beast/cxx14/memory.h> // <memory>
#include <mutex>
namespace ripple {
@@ -277,9 +278,8 @@ private:
using MapType = hash_map <uint256, InboundTransactionSet>;
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::unique_lock <LockType>;
LockType mLock;
using ScopedLockType = std::lock_guard <std::recursive_mutex>;
std::recursive_mutex mLock;
MapType m_map;
std::uint32_t m_seq;

View File

@@ -1,33 +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_BASICTYPES_H_INCLUDED
#define RIPPLE_BASICS_BASICTYPES_H_INCLUDED
#include <mutex>
namespace ripple {
// VFALCO DEPRECATED
using RippleMutex = std::mutex;
using RippleRecursiveMutex = std::recursive_mutex;
} // ripple
#endif

View File

@@ -20,7 +20,6 @@
#ifndef RIPPLE_CORE_JOB_H_INCLUDED
#define RIPPLE_CORE_JOB_H_INCLUDED
#include <ripple/basics/BasicTypes.h>
#include <ripple/core/LoadMonitor.h>
namespace ripple {

View File

@@ -27,6 +27,7 @@
#include <beast/chrono/abstract_clock.h>
#include <beast/utility/Journal.h>
#include <boost/asio/deadline_timer.hpp>
#include <mutex>
namespace ripple {
@@ -117,9 +118,7 @@ private:
static void timerJobEntry (std::shared_ptr<PeerSet>);
protected:
// VFALCO TODO try to make some of these private
using LockType = RippleRecursiveMutex;
using ScopedLockType = std::unique_lock <LockType>;
using ScopedLockType = std::unique_lock <std::recursive_mutex>;
PeerSet (Application& app, uint256 const& hash, int interval, bool txnData,
clock_type& clock, beast::Journal journal);
@@ -161,7 +160,7 @@ protected:
beast::Journal m_journal;
clock_type& m_clock;
LockType mLock;
std::recursive_mutex mLock;
uint256 mHash;
int mTimerInterval;

View File

@@ -20,7 +20,6 @@
#ifndef RIPPLE_PROTOCOL_SFIELD_H_INCLUDED
#define RIPPLE_PROTOCOL_SFIELD_H_INCLUDED
#include <ripple/basics/BasicTypes.h>
#include <ripple/json/json_value.h>
#include <cstdint>
#include <utility>

View File

@@ -21,6 +21,7 @@
#include <ripple/protocol/SField.h>
#include <map>
#include <memory>
#include <mutex>
#include <string>
#include <utility>