aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/metrics/simple_tick.h
blob: 457281fd8a9ee1e1b0e9108d1dcc3d469a337d41 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "clock.h"

#include <atomic>
#include <condition_variable>
#include <mutex>

namespace vespalib::metrics {

// internal
class SimpleTick : public Tick {
private:
    std::mutex _lock;
    std::atomic<bool> _runFlag;
    std::condition_variable _cond;
public:
    SimpleTick();
    TimeStamp first() override;
    TimeStamp next(TimeStamp prev) override;
    void kill() override;
    bool alive() const override;
};

} // namespace vespalib::metrics