/*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#pragma once
#include <folly/futures/detail/Types.h>
-#include <folly/futures/Unit.h>
+#include <folly/Unit.h>
namespace folly {
/// it made sense to introduce a cleaner term.
///
/// Remember that Duration is a std::chrono duration (millisecond resolution
-/// at the time of writing).
+/// at the time of writing). When writing code that uses specific durations,
+/// prefer using the explicit std::chrono type, e.g. std::chrono::milliseconds
+/// over Duration. This makes the code more legible and means you won't be
+/// unpleasantly surprised if we redefine Duration to microseconds, or
+/// something.
+///
+/// timekeeper.after(std::chrono::duration_cast<Duration>(
+/// someNanoseconds))
class Timekeeper {
public:
virtual ~Timekeeper() = default;
return makeFuture();
}
- return after(when - now);
+ return after(std::chrono::duration_cast<Duration>(when - now));
}
} // namespace folly