aboutsummaryrefslogtreecommitdiffstats
path: root/slobrok/src/vespa/slobrok/server/reserved_name.cpp
blob: 09187c5af443000d17246395dc48fa5c20af7907 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "reserved_name.h"

using std::chrono::duration_cast;

namespace slobrok {

ReservedName::ReservedName(const std::string &name, const std::string &spec, bool local)
    : NamedService(name, spec),
      _reservedTime(steady_clock::now()),
      isLocal(local)
{ }

bool
ReservedName::stillReserved() const {
    return (milliseconds() < 15000);
}

int64_t ReservedName::milliseconds() const {
    return duration_cast<std::chrono::milliseconds>(steady_clock::now() - _reservedTime).count();
}

}