aboutsummaryrefslogtreecommitdiffstats
path: root/staging_vespalib/src/vespa/vespalib/util/testclock.h
blob: 54e9f1efb6a7f62fb71aca071a930d64a5abc281 (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
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#pragma once

#include "clock.h"

namespace vespalib {

class InvokeServiceImpl;

/**
 * Clock is a clock that updates the time at defined intervals.
 * It is intended used where you want to check the time with low cost, but where
 * resolution is not that important.
 */

class TestClock
{
private:
    std::unique_ptr<InvokeServiceImpl> _ticker;
    Clock _clock;
public:
    TestClock();
    TestClock(const TestClock &) = delete;
    TestClock & operator =(const TestClock &) = delete;
    TestClock(TestClock &&) = delete;
    TestClock & operator =(TestClock &&) = delete;
    ~TestClock();
    const Clock & clock() { return _clock; }
};

}