futures: fix behaviour when executors don't exec callback
[folly.git] / folly / futures / Future.cpp
index bbab4003741f11757cb4ccc73d6bf17296a80ad4..be3683ae1dbbf43dd0765438cb3707451ef9be8c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * 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.
@@ -32,8 +32,10 @@ template class Future<double>;
 namespace folly { namespace futures {
 
 Future<Unit> sleep(Duration dur, Timekeeper* tk) {
+  std::shared_ptr<Timekeeper> tks;
   if (LIKELY(!tk)) {
-    tk = folly::detail::getTimekeeperSingleton();
+    tks = folly::detail::getTimekeeperSingleton();
+    tk = DCHECK_NOTNULL(tks.get());
   }
   return tk->after(dur);
 }