Remove Journal from most Stoppable overrides

This commit is contained in:
Vinnie Falco
2013-10-04 00:13:25 -07:00
parent 48eb92e366
commit a2aa938e10
20 changed files with 76 additions and 82 deletions

View File

@@ -65,47 +65,47 @@ void Stoppable::stopped ()
m_stoppedEvent.signal();
}
void Stoppable::onPrepare (Journal journal)
void Stoppable::onPrepare ()
{
}
void Stoppable::onStart (Journal journal)
void Stoppable::onStart ()
{
}
void Stoppable::onStop (Journal journal)
void Stoppable::onStop ()
{
stopped();
}
void Stoppable::onChildrenStopped (Journal journal)
void Stoppable::onChildrenStopped ()
{
}
//------------------------------------------------------------------------------
void Stoppable::prepareRecursive (Journal journal)
void Stoppable::prepareRecursive ()
{
onPrepare (journal);
for (Children::const_iterator iter (m_children.cbegin ());
iter != m_children.cend(); ++iter)
iter->stoppable->prepareRecursive (journal);
iter->stoppable->prepareRecursive ();
onPrepare ();
}
void Stoppable::startRecursive (Journal journal)
void Stoppable::startRecursive ()
{
onStart (journal);
onStart ();
for (Children::const_iterator iter (m_children.cbegin ());
iter != m_children.cend(); ++iter)
iter->stoppable->startRecursive (journal);
iter->stoppable->startRecursive ();
}
void Stoppable::stopAsyncRecursive (Journal journal)
void Stoppable::stopAsyncRecursive ()
{
onStop (journal);
onStop ();
for (Children::const_iterator iter (m_children.cbegin ());
iter != m_children.cend(); ++iter)
iter->stoppable->stopAsyncRecursive (journal);
iter->stoppable->stopAsyncRecursive ();
}
void Stoppable::stopRecursive (Journal journal)
@@ -120,7 +120,7 @@ void Stoppable::stopRecursive (Journal journal)
//
memoryBarrier ();
m_childrenStopped = true;
onChildrenStopped (journal);
onChildrenStopped ();
// Now block on this Stoppable.
//
@@ -151,30 +151,24 @@ bool RootStoppable::isStopping() const
return m_calledStopAsync.get() != 0;
}
void RootStoppable::prepare (Journal journal)
void RootStoppable::prepare ()
{
if (! m_prepared.compareAndSetBool (1, 0))
{
journal.warning << "Stoppable::prepare called again";
return;
prepareRecursive ();
}
prepareRecursive (journal);
}
void RootStoppable::start (Journal journal)
void RootStoppable::start ()
{
// Courtesy call to prepare.
if (m_prepared.compareAndSetBool (1, 0))
prepareRecursive (journal);
prepareRecursive ();
if (! m_started.compareAndSetBool (1, 0))
{
journal.warning << "Stoppable::start called again";
return;
}
startRecursive (journal);
startRecursive ();
}
void RootStoppable::stop (Journal journal)
@@ -185,14 +179,14 @@ void RootStoppable::stop (Journal journal)
return;
}
stopAsync (journal);
stopAsync ();
stopRecursive (journal);
}
void RootStoppable::stopAsync (Journal journal)
void RootStoppable::stopAsync ()
{
if (! m_calledStopAsync.compareAndSetBool (1, 0))
return;
stopAsyncRecursive (journal);
stopAsyncRecursive ();
}

View File

@@ -185,10 +185,10 @@ public:
The default implementation does nothing.
Guaranteed to only be called once.
*/
virtual void onPrepare (Journal journal);
virtual void onPrepare ();
/** Override called during start. */
virtual void onStart (Journal journal);
virtual void onStart ();
/** Override called when the stop notification is issued.
@@ -211,7 +211,7 @@ public:
Guaranteed only to be called once.
Must be safe to call from any thread at any time.
*/
virtual void onStop (Journal journal);
virtual void onStop ();
/** Override called when all children have stopped.
@@ -231,7 +231,7 @@ public:
Guaranteed only to be called once.
Must be safe to call from any thread at any time.
*/
virtual void onChildrenStopped (Journal journal);
virtual void onChildrenStopped ();
private:
friend class RootStoppable;
@@ -248,9 +248,9 @@ private:
Stoppable* stoppable;
};
void prepareRecursive (Journal journal);
void startRecursive (Journal journal);
void stopAsyncRecursive (Journal journal);
void prepareRecursive ();
void startRecursive ();
void stopAsyncRecursive ();
void stopRecursive (Journal journal);
protected:
@@ -280,7 +280,7 @@ public:
Thread safety:
May be called from any thread.
*/
void prepare (Journal journal = Journal());
void prepare ();
/** Start all contained Stoppable objects.
The default implementation does nothing.
@@ -288,7 +288,7 @@ public:
Thread safety:
May be called from any thread.
*/
void start (Journal journal = Journal());
void start ();
/** Notify a root stoppable and children to stop, and block until stopped.
Has no effect if the stoppable was already notified.
@@ -304,7 +304,7 @@ public:
Thread safety:
Safe to call from any thread at any time.
*/
void stopAsync (Journal journal = Journal());
void stopAsync ();
private:
Atomic <int> m_prepared;

View File

@@ -270,16 +270,16 @@ public:
// Stoppable
//
void onPrepare (Journal journal)
void onPrepare ()
{
}
void onStart (Journal journal)
void onStart ()
{
startThread();
}
void onStop (Journal journal)
void onStop ()
{
if (this->Thread::isThreadRunning ())
{

View File

@@ -255,19 +255,19 @@ public:
// Stoppable
//
void onPrepare (Journal journal)
void onPrepare ()
{
#if RIPPLE_USE_NEW_VALIDATORS
journal.info << "Validators preparing";
m_journal.info << "Validators preparing";
addRPCHandlers();
#endif
}
void onStart (Journal journal)
void onStart ()
{
#if RIPPLE_USE_NEW_VALIDATORS
journal.info << "Validators starting";
m_journal.info << "Validators starting";
// Do this late so the sources have a chance to be added.
m_queue.dispatch (bind (&ManagerImp::setCheckSources, this));
@@ -276,9 +276,9 @@ public:
#endif
}
void onStop (Journal journal)
void onStop ()
{
journal.info << "Validators stopping";
m_journal.info << "Validators stopping";
if (this->Thread::isThreadRunning())
{

View File

@@ -351,7 +351,7 @@ Json::Value InboundLedgers::getInfo()
return ret;
}
void InboundLedgers::onStop (Journal)
void InboundLedgers::onStop ()
{
ScopedLockType lock (mLock, __FILE__, __LINE__);

View File

@@ -76,7 +76,7 @@ public:
void gotFetchPack (Job&);
void sweep ();
void onStop (Journal);
void onStop ();
private:
typedef boost::unordered_map <uint256, InboundLedger::pointer> MapType;

View File

@@ -641,22 +641,22 @@ public:
// Stoppable
//
void onPrepare (Journal)
void onPrepare ()
{
prepareValidators ();
}
void onStart (Journal journal)
void onStart ()
{
journal.debug << "Application starting";
m_journal.debug << "Application starting";
m_sweepTimer.setExpiration (10);
}
// Called to indicate shutdown.
void onStop (Journal journal)
void onStop ()
{
journal.debug << "Application stopping";
m_journal.debug << "Application stopping";
m_sweepTimer.cancel();
@@ -679,8 +679,8 @@ public:
// crash), the run() function will not get called and we will
// avoid doing silly things like contacting the SNTP server, or
// running the various logic threads like Validators, PeerFinder, etc.
prepare (m_journal);
start (m_journal);
prepare ();
start ();
{

View File

@@ -90,7 +90,7 @@ IoServicePool::operator boost::asio::io_service& ()
return m_service;
}
void IoServicePool::onStop (Journal)
void IoServicePool::onStop ()
{
// VFALCO NOTE This is a hack! We should gracefully
// cancel all pending I/O, and delete the work
@@ -100,7 +100,7 @@ void IoServicePool::onStop (Journal)
m_service.stop ();
}
void IoServicePool::onChildrenStopped (Journal)
void IoServicePool::onChildrenStopped ()
{
}

View File

@@ -31,8 +31,8 @@ public:
boost::asio::io_service& getService ();
operator boost::asio::io_service& ();
void onStop (Journal);
void onChildrenStopped (Journal);
void onStop ();
void onChildrenStopped ();
private:
class ServiceThread;

View File

@@ -155,21 +155,21 @@ public:
// Stoppable
//
void onPrepare (Journal)
void onPrepare ()
{
}
void onStart (Journal journal)
void onStart ()
{
journal.debug << "Starting";
m_journal.debug << "Starting";
startThread ();
}
void onStop (Journal journal)
void onStop ()
{
if (isThreadRunning ())
{
journal.debug << "Stopping";
m_journal.debug << "Stopping";
stopThreadAsync ();
}
else

View File

@@ -25,13 +25,13 @@ NodeStoreScheduler::NodeStoreScheduler (Stoppable& parent, JobQueue& jobQueue)
{
}
void NodeStoreScheduler::onStop (Journal)
void NodeStoreScheduler::onStop ()
{
if (--m_taskCount == 0)
stopped();
}
void NodeStoreScheduler::onChildrenStopped (Journal)
void NodeStoreScheduler::onChildrenStopped ()
{
}

View File

@@ -29,8 +29,8 @@ class NodeStoreScheduler
public:
NodeStoreScheduler (Stoppable& parent, JobQueue& jobQueue);
void onStop (Journal);
void onChildrenStopped (Journal);
void onStop ();
void onChildrenStopped ();
void scheduleTask (NodeStore::Task& task);
private:

View File

@@ -92,12 +92,12 @@ public:
// Stoppable
//
void onStop (Journal)
void onStop ()
{
m_server.stopAsync();
}
void onChildrenStopped (Journal)
void onChildrenStopped ()
{
}

View File

@@ -376,7 +376,7 @@ public:
//
// Stoppable
void onStop (Journal)
void onStop ()
{
m_heartbeatTimer.cancel();
m_clusterTimer.cancel();

View File

@@ -107,7 +107,7 @@ public:
//--------------------------------------------------------------------------
void onStop (Journal)
void onStop ()
{
{
boost::system::error_code ec;

View File

@@ -202,20 +202,20 @@ public:
// Stoppable
//
void onPrepare (Journal)
void onPrepare ()
{
preparePeerFinder();
}
void onStart (Journal)
void onStart ()
{
}
void onStop (Journal)
void onStop ()
{
}
void onChildrenStopped (Journal)
void onChildrenStopped ()
{
// VFALCO TODO Clean this up and do it right, based on sockets
stopped();

View File

@@ -115,7 +115,7 @@ public:
//--------------------------------------------------------------------------
void onStop (Journal)
void onStop ()
{
m_fetchTimer.cancel ();
m_scoreTimer.cancel ();

View File

@@ -112,7 +112,7 @@ private:
stopped ();
}
void onStop (Journal)
void onStop ()
{
{
ScopedLockType lock (m_endpointLock, __FILE__, __LINE__);

View File

@@ -645,7 +645,7 @@ private:
//--------------------------------------------------------------------------
void onStop (Journal)
void onStop ()
{
// VFALCO NOTE I wanted to remove all the jobs that are skippable
// but then the Workers count of tasks to process
@@ -697,7 +697,7 @@ private:
*/
}
void onChildrenStopped (Journal)
void onChildrenStopped ()
{
ScopedLock lock (m_mutex);

View File

@@ -114,7 +114,7 @@ public:
stopped ();
}
void onStop (Journal)
void onStop ()
{
// HACK!
m_io_service.stop ();