sapling/eden/fs/testharness/FakeClock.h
Adam Simpkins 00a232d868 make Clock::getRealtime() const
Summary: This API seems like it should be const, as it does not modify the clock.

Reviewed By: chadaustin, zhupanov

Differential Revision: D6869719

fbshipit-source-id: c8bf4ccab34538b59e6baeedd0b0ff88b328236e
2018-02-01 11:19:15 -08:00

47 lines
956 B
C++

/*
* Copyright (c) 2017-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include "eden/fs/utils/Clock.h"
#include <folly/chrono/Conv.h>
namespace facebook {
namespace eden {
class FakeClock : public Clock {
public:
using clock = std::chrono::system_clock;
using time_point = clock::time_point;
using duration = clock::duration;
timespec getRealtime() const override {
return folly::to<timespec>(currentTime_);
}
time_point getTimePoint() const {
return currentTime_;
}
void set(time_point to) {
currentTime_ = to;
}
void advance(duration by) {
currentTime_ += by;
}
private:
time_point currentTime_;
};
} // namespace eden
} // namespace facebook