mirror of
https://github.com/facebook/sapling.git
synced 2024-10-10 08:47:12 +03:00
fbdb46f5cb
Reviewed By: chadaustin Differential Revision: D17872966 fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
45 lines
819 B
C++
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
|