blob: bbb51fe4f1f7623105c2604246709b1398b05700 (
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 Vespa.ai. 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;
}
}
|