aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/vespa/vespalib/metrics/simple_tick.h
blob: 8ab18e74c8380ae7c96b4bd31d052fdf3838b2e7 (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 Yahoo. 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