aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/util/fake_doom.h
blob: 78fc9d0f38a75d8b6f29bb32ad3a01ec4815c11a (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include "doom.h"

namespace vespalib {

/*
 * Class containing a fake doom controlled by the time_to_doom
 * constructor argument.
 */
class FakeDoom {
    std::atomic<steady_time> _time;
    Clock                    _clock;
    Doom                     _doom;
public:
    FakeDoom() : FakeDoom(1s) { }
    FakeDoom(steady_time::duration time_to_doom);
    ~FakeDoom();
    const Doom& get_doom() const noexcept { return _doom; }
};

}