diff --git a/modules/ripple_core/functional/ripple_Job.h b/modules/ripple_core/functional/ripple_Job.h index d1305d7ad8..55d54f2f3e 100644 --- a/modules/ripple_core/functional/ripple_Job.h +++ b/modules/ripple_core/functional/ripple_Job.h @@ -28,8 +28,9 @@ enum JobType jtWRITE = 13, // Write out hashed objects jtTRANSACTION_l = 14, // A local transaction jtPROPOSAL_t = 15, // A proposal from a trusted source - jtADMIN = 16, // An administrative operation - jtDEATH = 17, // job of death, used internally + jtSWEEP = 16, // Sweep for stale structures + jtADMIN = 17, // An administrative operation + jtDEATH = 18, // job of death, used internally // special types not dispatched by the job pool jtPEER = 24, @@ -40,6 +41,7 @@ enum JobType jtPATH_FIND = 29, jtHO_READ = 30, jtHO_WRITE = 31, + jtGENERIC = 32, // Used just to measure time }; // CAUTION: If you add new types, add them to JobType.cpp too // VFALCO TODO move this into the enum so it calculates itself? diff --git a/src/cpp/ripple/ripple_Application.cpp b/src/cpp/ripple/ripple_Application.cpp index 9749eb98be..8c87ba70bf 100644 --- a/src/cpp/ripple/ripple_Application.cpp +++ b/src/cpp/ripple/ripple_Application.cpp @@ -277,6 +277,7 @@ public: void run (); void stop (); void sweep (); + void doSweep (Job&); private: void updateTables (); @@ -684,10 +685,17 @@ void ApplicationImp::sweep () getApp().stop (); } + mJobQueue.addJob(jtSWEEP, "sweep", + BIND_TYPE(&ApplicationImp::doSweep, this, P_1)); +} + +void ApplicationImp::doSweep(Job& j) +{ // VFALCO NOTE Does the order of calls matter? // VFALCO TODO fix the dependency inversion using an observer, // have listeners register for "onSweep ()" notification. // + mMasterTransaction.sweep (); m_nodeStore.sweep (); mLedgerMaster.sweep (); @@ -698,7 +706,7 @@ void ApplicationImp::sweep () AcceptedLedger::sweep (); // VFALCO NOTE AcceptedLedger is/has a singleton? SHAMap::sweep (); // VFALCO NOTE SHAMap is/has a singleton? mNetOps.sweepFetchPack (); - // VFALCO NOTE does the call to sweep() happen on another thread? + mSweepTimer.expires_from_now (boost::posix_time::seconds (theConfig.getSize (siSweepInterval))); mSweepTimer.async_wait (BIND_TYPE (&ApplicationImp::sweep, this)); }