aboutsummaryrefslogtreecommitdiffstats
path: root/config/src/vespa/config/common/configholder.h
blob: 454710cc8d4c090ff3cbf2301ec2f11d7e6c1c88 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "iconfigholder.h"
#include <mutex>
#include <condition_variable>

namespace config {

/**
 * A config holder contains the latest config object of a subscription.
 */
class ConfigHolder : public IConfigHolder
{
public:
    ConfigHolder();
    ~ConfigHolder() override;

    std::unique_ptr<ConfigUpdate> provide() override;
    void handle(std::unique_ptr<ConfigUpdate> update) override;
    bool wait_until(vespalib::steady_time deadline) override;
    bool poll() override;
    void close() override;
public:
    std::mutex                    _lock;
    std::condition_variable       _cond;
    std::unique_ptr<ConfigUpdate> _current;
};

} // namespace config