aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/net/http/simple_component_config_producer.cpp
blob: 3fa5f09033fa479a95a2308cd87e245ee50adff4 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "simple_component_config_producer.h"

namespace vespalib {

SimpleComponentConfigProducer::SimpleComponentConfigProducer()
    : _lock(),
      _state()
{
}

SimpleComponentConfigProducer::~SimpleComponentConfigProducer() = default;

void
SimpleComponentConfigProducer::addConfig(const Config &config)
{
    std::lock_guard guard(_lock);
    _state.insert(std::make_pair(config.name, config)).first->second = config;
}

void
SimpleComponentConfigProducer::removeConfig(const vespalib::string &name)
{
    std::lock_guard guard(_lock);
    _state.erase(name);
}

void
SimpleComponentConfigProducer::getComponentConfig(Consumer &consumer)
{
    std::lock_guard guard(_lock);
    for (const auto & entry : _state) {
        consumer.add(entry.second);
    }
}

} // namespace vespalib