blob: 1b0d1e0d16b01a74824f018f5903f248798839e8 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "configholder.h"
namespace config {
ConfigHolder::ConfigHolder()
: _monitor(),
_current()
{
}
ConfigUpdate::UP
ConfigHolder::provide()
{
vespalib::MonitorGuard guard(_monitor);
ConfigUpdate::UP ret(new ConfigUpdate(*_current));
return ret;
}
void
ConfigHolder::handle(ConfigUpdate::UP update)
{
vespalib::MonitorGuard guard(_monitor);
_current = std::move(update);
guard.broadcast();
}
bool
ConfigHolder::wait(uint64_t timeoutInMillis)
{
vespalib::MonitorGuard guard(_monitor);
return guard.wait(timeoutInMillis);
}
bool
ConfigHolder::poll()
{
vespalib::MonitorGuard guard(_monitor);
return (_current.get() != NULL);
}
void
ConfigHolder::interrupt()
{
vespalib::MonitorGuard guard(_monitor);
guard.broadcast();
}
} // namespace config
|