don't try to run the poly tests on gcc-4.9. they will fail.
[folly.git] / folly / futures / Timekeeper.h
index 3e3e20a775fccd08522b0ed6bfb4cf2cb2517b6c..f5223f43f80a5384c49a4dd8f4a2c3f20efd90a8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,8 +16,8 @@
 
 #pragma once
 
+#include <folly/Unit.h>
 #include <folly/futures/detail/Types.h>
-#include <folly/futures/Unit.h>
 
 namespace folly {
 
@@ -41,7 +41,14 @@ template <class> class Future;
 /// 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;
@@ -85,7 +92,7 @@ Future<Unit> Timekeeper::at(std::chrono::time_point<Clock> when) {
     return makeFuture();
   }
 
-  return after(when - now);
+  return after(std::chrono::duration_cast<Duration>(when - now));
 }
 
 } // namespace folly