Remove some shared pointers on load monitors.

This commit is contained in:
JoelKatz
2012-11-28 15:53:07 -08:00
parent 8ba70c73f6
commit 72777b6b83
9 changed files with 15 additions and 11 deletions

View File

@@ -61,7 +61,7 @@ void HashedObjectStore::waitWrite()
void HashedObjectStore::bulkWrite() void HashedObjectStore::bulkWrite()
{ {
LoadEvent::pointer event = theApp->getJobQueue().getLoadEvent(jtDISK); LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK));
while (1) while (1)
{ {
std::vector< boost::shared_ptr<HashedObject> > set; std::vector< boost::shared_ptr<HashedObject> > set;

View File

@@ -104,6 +104,8 @@ public:
LoadEvent::pointer getLoadEvent(JobType t) LoadEvent::pointer getLoadEvent(JobType t)
{ return boost::make_shared<LoadEvent>(boost::ref(mJobLoads[t]), true, 1); } { return boost::make_shared<LoadEvent>(boost::ref(mJobLoads[t]), true, 1); }
LoadEvent::autoptr getLoadEventAP(JobType t)
{ return LoadEvent::autoptr(new LoadEvent(mJobLoads[t], true, 1)); }
Json::Value getJson(int c = 0); Json::Value getJson(int c = 0);
}; };

View File

@@ -339,9 +339,8 @@ uint256 Ledger::getHash()
return mHash; return mHash;
} }
void Ledger::saveAcceptedLedger(bool fromConsensus) void Ledger::saveAcceptedLedger(bool fromConsensus, LoadEvent::pointer event)
{ // can be called in a different thread { // can be called in a different thread
LoadEvent::pointer event = theApp->getJobQueue().getLoadEvent(jtDISK);
cLog(lsTRACE) << "saveAcceptedLedger " << (fromConsensus ? "fromConsensus " : "fromAcquire ") << getLedgerSeq(); cLog(lsTRACE) << "saveAcceptedLedger " << (fromConsensus ? "fromConsensus " : "fromAcquire ") << getLedgerSeq();
static boost::format ledgerExists("SELECT LedgerSeq FROM Ledgers where LedgerSeq = %d;"); static boost::format ledgerExists("SELECT LedgerSeq FROM Ledgers where LedgerSeq = %d;");
static boost::format deleteLedger("DELETE FROM Ledgers WHERE LedgerSeq = %d;"); static boost::format deleteLedger("DELETE FROM Ledgers WHERE LedgerSeq = %d;");
@@ -439,7 +438,7 @@ void Ledger::saveAcceptedLedger(bool fromConsensus)
} }
theApp->getLedgerMaster().setFullLedger(shared_from_this()); theApp->getLedgerMaster().setFullLedger(shared_from_this());
event = LoadEvent::pointer(); event->stop();
theApp->getOPs().pubLedger(shared_from_this()); theApp->getOPs().pubLedger(shared_from_this());
@@ -1136,7 +1135,8 @@ void Ledger::pendSave(bool fromConsensus)
if (!fromConsensus && !theApp->isNewFlag(getHash(), SF_SAVED)) if (!fromConsensus && !theApp->isNewFlag(getHash(), SF_SAVED))
return; return;
boost::thread thread(boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(), fromConsensus)); boost::thread thread(boost::bind(&Ledger::saveAcceptedLedger, shared_from_this(),
fromConsensus, theApp->getJobQueue().getLoadEvent(jtDISK)));
thread.detach(); thread.detach();
boost::recursive_mutex::scoped_lock sl(sPendingSaveLock); boost::recursive_mutex::scoped_lock sl(sPendingSaveLock);

View File

@@ -19,6 +19,7 @@
#include "BitcoinUtil.h" #include "BitcoinUtil.h"
#include "SHAMap.h" #include "SHAMap.h"
#include "InstanceCounter.h" #include "InstanceCounter.h"
#include "LoadMonitor.h"
enum LedgerStateParms enum LedgerStateParms
{ {
@@ -93,7 +94,7 @@ protected:
static void incPendingSaves(); static void incPendingSaves();
static void decPendingSaves(); static void decPendingSaves();
void saveAcceptedLedger(bool fromConsensus); void saveAcceptedLedger(bool fromConsensus, LoadEvent::pointer);
public: public:
Ledger(const RippleAddress& masterID, uint64 startAmount); // used for the starting bootstrap ledger Ledger(const RippleAddress& masterID, uint64 startAmount); // used for the starting bootstrap ledger

View File

@@ -36,7 +36,8 @@ public:
class LoadEvent class LoadEvent
{ {
public: public:
typedef boost::shared_ptr<LoadEvent> pointer; typedef boost::shared_ptr<LoadEvent> pointer;
typedef std::auto_ptr<LoadEvent> autoptr;
protected: protected:
LoadMonitor& mMonitor; LoadMonitor& mMonitor;

View File

@@ -1002,7 +1002,7 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
if (NetworkOPs::omDISCONNECTED == getOperatingMode()) if (NetworkOPs::omDISCONNECTED == getOperatingMode())
return; return;
LoadEvent::pointer event = theApp->getJobQueue().getLoadEvent(jtPUBLEDGER); LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtPUBLEDGER));
{ {
boost::recursive_mutex::scoped_lock sl(mMonitorLock); boost::recursive_mutex::scoped_lock sl(mMonitorLock);

View File

@@ -373,7 +373,7 @@ void Peer::processReadBuffer()
// std::cerr << "Peer::processReadBuffer: " << mIpPort.first << " " << mIpPort.second << std::endl; // std::cerr << "Peer::processReadBuffer: " << mIpPort.first << " " << mIpPort.second << std::endl;
LoadEvent::pointer event = theApp->getJobQueue().getLoadEvent(jtPEER); LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtPEER));
boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock()); boost::recursive_mutex::scoped_lock sl(theApp->getMasterLock());

View File

@@ -1482,7 +1482,7 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
cLog(lsTRACE) << "RPC:" << command; cLog(lsTRACE) << "RPC:" << command;
cLog(lsTRACE) << "RPC params:" << params; cLog(lsTRACE) << "RPC params:" << params;
LoadEvent::pointer le = theApp->getJobQueue().getLoadEvent(jtRPC); LoadEvent::autoptr le(theApp->getJobQueue().getLoadEventAP(jtRPC));
mRole = role; mRole = role;

View File

@@ -289,7 +289,7 @@ void ValidationCollection::condWrite()
void ValidationCollection::doWrite() void ValidationCollection::doWrite()
{ {
LoadEvent::pointer event = theApp->getJobQueue().getLoadEvent(jtDISK); LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK));
static boost::format insVal("INSERT INTO LedgerValidations " static boost::format insVal("INSERT INTO LedgerValidations "
"(LedgerHash,NodePubKey,Flags,SignTime,Signature) VALUES ('%s','%s','%u','%u',%s);"); "(LedgerHash,NodePubKey,Flags,SignTime,Signature) VALUES ('%s','%s','%u','%u',%s);");