summaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/subscription/configsubscriber.cpp
blob: 092c460ece1c167c97ceaf8cbb587c33816d8c29 (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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/fastos/fastos.h>
#include <vespa/log/log.h>
LOG_SETUP(".config.subscription.configsubscriber");

#include "configsubscriber.h"
#include <vespa/config/common/exceptions.h>

namespace config {


ConfigSubscriber::ConfigSubscriber(const IConfigContext::SP & context)
    : _set(context)

{ }

ConfigSubscriber::ConfigSubscriber(const SourceSpec & spec)
    : _set(IConfigContext::SP(new ConfigContext(spec)))
{ }

bool
ConfigSubscriber::nextConfig(uint64_t timeoutInMillis)
{
    return _set.acquireSnapshot(timeoutInMillis, false);
}

bool
ConfigSubscriber::nextGeneration(uint64_t timeoutInMillis)
{
    return _set.acquireSnapshot(timeoutInMillis, true);
}

void
ConfigSubscriber::close()
{
    _set.close();
}

bool
ConfigSubscriber::isClosed() const
{
    return _set.isClosed();
}

int64_t
ConfigSubscriber::getGeneration() const
{
    return _set.getGeneration();
}

} // namespace config