Skip to content

Commit

Permalink
fix windows compile: medida::TimerContext is not copyable
Browse files Browse the repository at this point in the history
  • Loading branch information
MonsieurNicolas committed Jul 11, 2019
1 parent 924ad4e commit 1d911a8
Showing 1 changed file with 36 additions and 34 deletions.
70 changes: 36 additions & 34 deletions src/bucket/FutureBucket.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,43 +297,45 @@ FutureBucket::startMerge(Application& app, uint32_t maxProtocolVersion,
availableTime.Update(getAvailableTimeForMerge(app, level));

using task_t = std::packaged_task<std::shared_ptr<Bucket>()>;
std::shared_ptr<task_t> task = std::make_shared<task_t>([
curr, snap, &bm, shadows, maxProtocolVersion, countMergeEvents, level,
timeScope = timer.TimeScope(), &app
]() mutable {
CLOG(TRACE, "Bucket")
<< "Worker merging curr=" << hexAbbrev(curr->getHash())
<< " with snap=" << hexAbbrev(snap->getHash());

try
{
auto res = Bucket::merge(
bm, maxProtocolVersion, curr, snap, shadows,
BucketList::keepDeadEntries(level), countMergeEvents);

std::shared_ptr<task_t> task = std::make_shared<task_t>(
[curr, snap, &bm, shadows, maxProtocolVersion, countMergeEvents, level,
&timer, &app]() mutable {
auto timeScope = timer.TimeScope();
CLOG(TRACE, "Bucket")
<< "Worker finished merging curr=" << hexAbbrev(curr->getHash())
<< "Worker merging curr=" << hexAbbrev(curr->getHash())
<< " with snap=" << hexAbbrev(snap->getHash());

std::chrono::duration<double> time(timeScope.Stop());
double timePct = time.count() /
getAvailableTimeForMerge(app, level).count() * 100;
CLOG(DEBUG, "Perf")
<< "Bucket merge on level " << level << " finished in "
<< time.count() << " seconds (" << timePct
<< "% of available time)";

return res;
}
catch (std::exception const& e)
{
throw std::runtime_error(fmt::format(
"Error merging bucket curr={} with snap={}: "
"{}. {}",
hexAbbrev(curr->getHash()), hexAbbrev(snap->getHash()),
e.what(), POSSIBLY_CORRUPTED_LOCAL_FS));
};
});
try
{
auto res = Bucket::merge(
bm, maxProtocolVersion, curr, snap, shadows,
BucketList::keepDeadEntries(level), countMergeEvents);

CLOG(TRACE, "Bucket")
<< "Worker finished merging curr="
<< hexAbbrev(curr->getHash())
<< " with snap=" << hexAbbrev(snap->getHash());

std::chrono::duration<double> time(timeScope.Stop());
double timePct = time.count() /
getAvailableTimeForMerge(app, level).count() *
100;
CLOG(DEBUG, "Perf")
<< "Bucket merge on level " << level << " finished in "
<< time.count() << " seconds (" << timePct
<< "% of available time)";

return res;
}
catch (std::exception const& e)
{
throw std::runtime_error(fmt::format(
"Error merging bucket curr={} with snap={}: "
"{}. {}",
hexAbbrev(curr->getHash()), hexAbbrev(snap->getHash()),
e.what(), POSSIBLY_CORRUPTED_LOCAL_FS));
};
});

mOutputBucket = task->get_future().share();
app.postOnBackgroundThread(bind(&task_t::operator(), task),
Expand Down

5 comments on commit 1d911a8

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from MonsieurNicolas
at MonsieurNicolas@1d911a8

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging MonsieurNicolas/stellar-core/windowsCompileFixTimerScope = 1d911a8 into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MonsieurNicolas/stellar-core/windowsCompileFixTimerScope = 1d911a8 merged ok, testing candidate = 2c70a7b

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 2c70a7b

Please sign in to comment.