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

@@ -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)
{