sapling/eden/fs/testharness/FakeClock.h
Andres Suarez fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00

45 lines
819 B
C++

/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#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