mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-20 19:15:54 +00:00
Use std::function in JobQueue.
This commit is contained in:
committed by
Nik Bougalis
parent
545b2fd6b1
commit
a6f866b4d8
@@ -642,11 +642,14 @@ void LedgerConsensusImp::handleLCL (uint256 const& lclHash)
|
|||||||
|
|
||||||
// Tell the ledger acquire system that we need the consensus ledger
|
// Tell the ledger acquire system that we need the consensus ledger
|
||||||
mAcquiringLedger = mPrevLedgerHash;
|
mAcquiringLedger = mPrevLedgerHash;
|
||||||
getApp().getJobQueue().addJob (jtADVANCE, "getConsensusLedger",
|
auto& previousHash = mPrevLedgerHash;
|
||||||
std::bind (
|
auto acquire = [previousHash] (Job&) {
|
||||||
&InboundLedgers::acquire,
|
getApp().getInboundLedgers().acquire(
|
||||||
&getApp().getInboundLedgers(),
|
previousHash, 0, InboundLedger::fcCONSENSUS);
|
||||||
mPrevLedgerHash, 0, InboundLedger::fcCONSENSUS));
|
};
|
||||||
|
getApp().getJobQueue().addJob (
|
||||||
|
jtADVANCE, "getConsensusLedger", acquire);
|
||||||
|
;
|
||||||
mHaveCorrectLCL = false;
|
mHaveCorrectLCL = false;
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -36,15 +36,11 @@ protected:
|
|||||||
JobQueue (char const* name, Stoppable& parent);
|
JobQueue (char const* name, Stoppable& parent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
using JobFunction = std::function <void (Job&)>;
|
||||||
virtual ~JobQueue () { }
|
virtual ~JobQueue () { }
|
||||||
|
|
||||||
// VFALCO NOTE Using boost::function here because Visual Studio 2012
|
virtual void addJob (
|
||||||
// std::function doesn't swallow return types.
|
JobType, std::string const& name, JobFunction const&) = 0;
|
||||||
//
|
|
||||||
// TODO Replace with std::function
|
|
||||||
//
|
|
||||||
virtual void addJob (JobType type,
|
|
||||||
std::string const& name, boost::function <void (Job&)> const& job) = 0;
|
|
||||||
|
|
||||||
// Jobs waiting at this priority
|
// Jobs waiting at this priority
|
||||||
virtual int getJobCount (JobType t) const = 0;
|
virtual int getJobCount (JobType t) const = 0;
|
||||||
|
|||||||
@@ -115,8 +115,8 @@ public:
|
|||||||
job_count = m_jobSet.size ();
|
job_count = m_jobSet.size ();
|
||||||
}
|
}
|
||||||
|
|
||||||
void addJob (JobType type, std::string const& name,
|
void addJob (
|
||||||
boost::function <void (Job&)> const& jobFunc) override
|
JobType type, std::string const& name, JobFunction const& func) override
|
||||||
{
|
{
|
||||||
assert (type != jtINVALID);
|
assert (type != jtINVALID);
|
||||||
|
|
||||||
@@ -166,7 +166,7 @@ public:
|
|||||||
|
|
||||||
std::pair <std::set <Job>::iterator, bool> result (
|
std::pair <std::set <Job>::iterator, bool> result (
|
||||||
m_jobSet.insert (Job (type, name, ++m_lastJob,
|
m_jobSet.insert (Job (type, name, ++m_lastJob,
|
||||||
data.load (), jobFunc, m_cancelCallback)));
|
data.load (), func, m_cancelCallback)));
|
||||||
queueJob (*result.first, lock);
|
queueJob (*result.first, lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ namespace {
|
|||||||
|
|
||||||
void runOnJobQueue(std::string const& name, Callback const& callback)
|
void runOnJobQueue(std::string const& name, Callback const& callback)
|
||||||
{
|
{
|
||||||
boost::function <void (Job&)> cb([callback] (Job&) { callback(); });
|
auto cb = [callback] (Job&) { callback(); };
|
||||||
getApp().getJobQueue().addJob(jtCLIENT, name, cb);
|
getApp().getJobQueue().addJob(jtCLIENT, name, cb);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user