blob: 5b25d4d124ef16a397a3a6dc2a3306311cba0d9b (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "commit_time_tracker.h"
namespace proton {
CommitTimeTracker::CommitTimeTracker(vespalib::duration visibilityDelay)
: _visibilityDelay(visibilityDelay),
_nextCommit(vespalib::steady_clock::now())
{
_nextCommit = _nextCommit + visibilityDelay;
}
bool
CommitTimeTracker::needCommit() const
{
if (hasVisibilityDelay()) {
vespalib::steady_time now(vespalib::steady_clock::now());
if (now > _nextCommit) {
_nextCommit = now + _visibilityDelay;
return true;
}
return false;
}
return false;
}
}
|