2017-12-05 20:55:27 +03:00
|
|
|
/*
|
2019-06-20 02:58:25 +03:00
|
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
2017-12-05 20:55:27 +03:00
|
|
|
*
|
2019-06-20 02:58:25 +03:00
|
|
|
* This software may be used and distributed according to the terms of the
|
|
|
|
* GNU General Public License version 2.
|
2017-12-05 20:55:27 +03:00
|
|
|
*/
|
2019-10-11 15:26:59 +03:00
|
|
|
|
2017-12-05 20:55:27 +03:00
|
|
|
#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;
|
2017-12-05 20:55:31 +03:00
|
|
|
using time_point = clock::time_point;
|
|
|
|
using duration = clock::duration;
|
2017-12-05 20:55:27 +03:00
|
|
|
|
2018-02-01 22:09:26 +03:00
|
|
|
timespec getRealtime() const override {
|
2017-12-05 20:55:31 +03:00
|
|
|
return folly::to<timespec>(currentTime_);
|
2017-12-05 20:55:27 +03:00
|
|
|
}
|
|
|
|
|
2017-12-05 20:55:31 +03:00
|
|
|
time_point getTimePoint() const {
|
|
|
|
return currentTime_;
|
2017-12-05 20:55:29 +03:00
|
|
|
}
|
|
|
|
|
2017-12-05 20:55:31 +03:00
|
|
|
void set(time_point to) {
|
|
|
|
currentTime_ = to;
|
2017-12-05 20:55:27 +03:00
|
|
|
}
|
|
|
|
|
2017-12-05 20:55:31 +03:00
|
|
|
void advance(duration by) {
|
|
|
|
currentTime_ += by;
|
2017-12-05 20:55:27 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2017-12-05 20:55:31 +03:00
|
|
|
time_point currentTime_;
|
2017-12-05 20:55:27 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace eden
|
|
|
|
} // namespace facebook
|