Cleanup code using move semantics

This commit is contained in:
seelabs
2020-04-10 14:07:31 -04:00
committed by manojsdoshi
parent 421417ab07
commit 6d28f2a8d9
25 changed files with 132 additions and 116 deletions

View File

@@ -148,10 +148,7 @@ insertDeliveredAmount(
auto const getCloseTime = [&info] { return info.closeTime; };
auto amt = getDeliveredAmount(
getLedgerIndex,
getCloseTime,
std::move(serializedTx),
transactionMeta);
getLedgerIndex, getCloseTime, serializedTx, transactionMeta);
if (amt)
{
meta[jss::delivered_amount] =
@@ -182,10 +179,7 @@ getDeliveredAmount(
return context.ledgerMaster.getCloseTimeBySeq(getLedgerIndex());
};
return getDeliveredAmount(
getLedgerIndex,
getCloseTime,
std::move(serializedTx),
transactionMeta);
getLedgerIndex, getCloseTime, serializedTx, transactionMeta);
}
return {};

View File

@@ -424,40 +424,43 @@ ShardArchiveHandler::complete(path dstPath)
}
}
auto wrapper = jobCounter_.wrap([=, dstPath = std::move(dstPath)](Job&) {
if (isStopping())
return;
// Make lambdas mutable captured vars can be moved from
auto wrapper =
jobCounter_.wrap([=, dstPath = std::move(dstPath)](Job&) mutable {
if (isStopping())
return;
// If not synced then defer and retry
auto const mode{app_.getOPs().getOperatingMode()};
if (mode != OperatingMode::FULL)
{
std::lock_guard lock(m_);
timer_.expires_from_now(static_cast<std::chrono::seconds>(
(static_cast<std::size_t>(OperatingMode::FULL) -
static_cast<std::size_t>(mode)) *
10));
// If not synced then defer and retry
auto const mode{app_.getOPs().getOperatingMode()};
if (mode != OperatingMode::FULL)
{
std::lock_guard lock(m_);
timer_.expires_from_now(static_cast<std::chrono::seconds>(
(static_cast<std::size_t>(OperatingMode::FULL) -
static_cast<std::size_t>(mode)) *
10));
auto wrapper =
timerCounter_.wrap([=, dstPath = std::move(dstPath)](
boost::system::error_code const& ec) {
if (ec != boost::asio::error::operation_aborted)
complete(std::move(dstPath));
});
auto wrapper = timerCounter_.wrap(
[=, dstPath = std::move(dstPath)](
boost::system::error_code const& ec) mutable {
if (ec != boost::asio::error::operation_aborted)
complete(std::move(dstPath));
});
if (!wrapper)
onClosureFailed(
"failed to wrap closure for operating mode timer", lock);
if (!wrapper)
onClosureFailed(
"failed to wrap closure for operating mode timer",
lock);
else
timer_.async_wait(*wrapper);
}
else
timer_.async_wait(*wrapper);
}
else
{
process(dstPath);
std::lock_guard lock(m_);
removeAndProceed(lock);
}
});
{
process(dstPath);
std::lock_guard lock(m_);
removeAndProceed(lock);
}
});
if (!wrapper)
{

View File

@@ -335,11 +335,7 @@ struct transactionPreProcessResult
transactionPreProcessResult() = delete;
transactionPreProcessResult(transactionPreProcessResult const&) = delete;
transactionPreProcessResult(transactionPreProcessResult&& rhs)
: first(std::move(rhs.first)) // VS2013 won't default this.
, second(std::move(rhs.second))
{
}
transactionPreProcessResult(transactionPreProcessResult&& rhs) = default;
transactionPreProcessResult&
operator=(transactionPreProcessResult const&) = delete;