Get the shared pointers out of the scoped lock stuff. We don't need it.

This commit is contained in:
JoelKatz
2012-11-28 15:27:20 -08:00
parent 725761d60e
commit 6aca65ff76
8 changed files with 14 additions and 12 deletions

View File

@@ -35,7 +35,7 @@ public:
DatabaseCon(const std::string& name, const char *initString[], int countInit);
~DatabaseCon();
Database* getDB() { return mDatabase; }
ScopedLock getDBLock() { return ScopedLock(mLock); }
boost::recursive_mutex& getDBLock() { return mLock; }
};
class Application

View File

@@ -53,7 +53,7 @@ bool HashedObjectStore::store(HashedObjectType type, uint32 index,
void HashedObjectStore::waitWrite()
{
boost::unique_lock<boost::mutex> sl(mWriteMutex);
boost::mutex::scoped_lock sl(mWriteMutex);
while (mWritePending)
mWriteCondition.wait(sl);
}
@@ -67,7 +67,7 @@ void HashedObjectStore::bulkWrite()
set.reserve(128);
{
boost::unique_lock<boost::mutex> sl(mWriteMutex);
boost::mutex::scoped_lock sl(mWriteMutex);
mWriteSet.swap(set);
assert(mWriteSet.empty());
if (set.empty())
@@ -85,7 +85,7 @@ void HashedObjectStore::bulkWrite()
Database* db = theApp->getHashNodeDB()->getDB();
{
ScopedLock sl = theApp->getHashNodeDB()->getDBLock();
ScopedLock sl( theApp->getHashNodeDB()->getDBLock());
db->executeSQL("BEGIN TRANSACTION;");

View File

@@ -369,7 +369,7 @@ void Ledger::saveAcceptedLedger(bool fromConsensus)
SHAMap& txSet = *peekTransactionMap();
Database *db = theApp->getTxnDB()->getDB();
ScopedLock dbLock = theApp->getTxnDB()->getDBLock();
ScopedLock dbLock(theApp->getTxnDB()->getDBLock());
db->executeSQL("BEGIN TRANSACTION;");
SHAMapTreeNode::TNType type;
for (SHAMapItem::pointer item = txSet.peekFirstItem(type); !!item;

View File

@@ -1251,7 +1251,7 @@ void LedgerConsensus::accept(SHAMap::ref set, LoadEvent::pointer)
cLog(lsINFO) << "CNF newLCL " << newLCLHash;
Ledger::pointer newOL = boost::make_shared<Ledger>(true, boost::ref(*newLCL));
ScopedLock sl = theApp->getLedgerMaster().getLock();
ScopedLock sl( theApp->getLedgerMaster().getLock());
// Apply disputed transactions that didn't get in
TransactionEngine engine(newOL);

View File

@@ -888,7 +888,7 @@ std::vector< std::pair<uint32, uint256> >
{
Database* db = theApp->getTxnDB()->getDB();
ScopedLock dbLock = theApp->getTxnDB()->getDBLock();
ScopedLock sl(theApp->getTxnDB()->getDBLock());
SQL_FOREACH(db, sql)
{
@@ -909,7 +909,7 @@ std::vector<RippleAddress>
RippleAddress acct;
{
Database* db = theApp->getTxnDB()->getDB();
ScopedLock dblock = theApp->getTxnDB()->getDBLock();
ScopedLock sl(theApp->getTxnDB()->getDBLock());
SQL_FOREACH(db, sql)
{
if (acct.setAccountID(db->getStrBinary("Account")))

View File

@@ -1158,7 +1158,7 @@ Json::Value RPCHandler::doTxHistory(const Json::Value& params)
{
Database* db = theApp->getTxnDB()->getDB();
ScopedLock dbLock = theApp->getTxnDB()->getDBLock();
ScopedLock sl (theApp->getTxnDB()->getDBLock());
SQL_FOREACH(db, sql)
{

View File

@@ -6,16 +6,18 @@
#include <boost/make_shared.hpp>
#include <boost/ref.hpp>
typedef boost::recursive_mutex::scoped_lock ScopedLock;
// A lock holder that can be returned and copied by value
// When the last reference goes away, the lock is released
class ScopedLock
class SharedScopedLock
{
protected:
mutable boost::shared_ptr<boost::recursive_mutex::scoped_lock> mHolder;
public:
ScopedLock(boost::recursive_mutex& mutex) :
SharedScopedLock(boost::recursive_mutex& mutex) :
mHolder(boost::make_shared<boost::recursive_mutex::scoped_lock>(boost::ref(mutex))) { ; }
void lock() const { mHolder->lock(); }

View File

@@ -150,7 +150,7 @@ bool Transaction::save()
% mTransaction->getTransactionID().GetHex());
Database *db = theApp->getTxnDB()->getDB();
ScopedLock dbLock = theApp->getTxnDB()->getDBLock();
ScopedLock dbLock(theApp->getTxnDB()->getDBLock());
if (SQL_EXISTS(db, exists)) return false;
return
db->executeSQL(mTransaction->getSQLInsertHeader() + mTransaction->getSQL(getLedger(), status) + ";");