/*
- * Copyright 2016 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.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+
#include <folly/futures/Future.h>
-#include <folly/futures/ThreadWheelTimekeeper.h>
#include <folly/Likely.h>
+#include <folly/futures/ThreadWheelTimekeeper.h>
namespace folly {
// Instantiate the most common Future types to save compile time
+template class SemiFuture<Unit>;
+template class SemiFuture<bool>;
+template class SemiFuture<int>;
+template class SemiFuture<int64_t>;
+template class SemiFuture<std::string>;
+template class SemiFuture<double>;
template class Future<Unit>;
template class Future<bool>;
template class Future<int>;
template class Future<int64_t>;
template class Future<std::string>;
template class Future<double>;
+} // namespace folly
-}
-
-namespace folly { namespace futures {
+namespace folly {
+namespace futures {
Future<Unit> sleep(Duration dur, Timekeeper* tk) {
std::shared_ptr<Timekeeper> tks;
if (LIKELY(!tk)) {
tks = folly::detail::getTimekeeperSingleton();
- tk = DCHECK_NOTNULL(tks.get());
+ tk = tks.get();
+ }
+
+ if (UNLIKELY(!tk)) {
+ return makeFuture<Unit>(NoTimekeeper());
}
+
return tk->after(dur);
}
-}}
+} // namespace futures
+} // namespace folly