projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Expose the time remaining in HHWheelTimer::Callback
[folly.git]
/
folly
/
futures
/
Promise.h
diff --git
a/folly/futures/Promise.h
b/folly/futures/Promise.h
index 379ad5d6fdc2b5c273a1cfeb5ff44110936370d6..7bb58d1e8abfaa61c9ff4f9d303848472013fa8d 100644
(file)
--- a/
folly/futures/Promise.h
+++ b/
folly/futures/Promise.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
6
Facebook, Inc.
+ * Copyright 201
7
Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@
-17,17
+17,31
@@
#pragma once
#include <folly/Portability.h>
#pragma once
#include <folly/Portability.h>
-#include <folly/
futures/
Try.h>
+#include <folly/Try.h>
#include <functional>
namespace folly {
// forward declaration
#include <functional>
namespace folly {
// forward declaration
+template <class T>
+class SemiFuture;
template <class T> class Future;
template <class T> class Future;
+namespace futures {
+namespace detail {
+template <class T>
+class FutureBase;
+struct EmptyConstruct {};
+template <typename T, typename F>
+class CoreCallbackState;
+} // namespace detail
+} // namespace futures
+
template <class T>
class Promise {
template <class T>
class Promise {
-public:
+ public:
+ static Promise<T> makeEmpty() noexcept; // equivalent to moved-from
+
Promise();
~Promise();
Promise();
~Promise();
@@
-93,11
+107,18
@@
public:
template <class F>
void setWith(F&& func);
template <class F>
void setWith(F&& func);
- bool isFulfilled();
+ bool isFulfilled()
const noexcept
;
-private:
+
private:
typedef typename Future<T>::corePtr corePtr;
typedef typename Future<T>::corePtr corePtr;
- template <class> friend class Future;
+ template <class>
+ friend class futures::detail::FutureBase;
+ template <class>
+ friend class SemiFuture;
+ template <class>
+ friend class Future;
+ template <class, class>
+ friend class futures::detail::CoreCallbackState;
// Whether the Future has been retrieved (a one-time operation).
bool retrieved_;
// Whether the Future has been retrieved (a one-time operation).
bool retrieved_;
@@
-105,12
+126,14
@@
private:
// shared core state object
corePtr core_;
// shared core state object
corePtr core_;
+ explicit Promise(futures::detail::EmptyConstruct) noexcept;
+
void throwIfFulfilled();
void throwIfRetrieved();
void detach();
};
void throwIfFulfilled();
void throwIfRetrieved();
void detach();
};
-}
+}
// namespace folly
#include <folly/futures/Future.h>
#include <folly/futures/Promise-inl.h>
#include <folly/futures/Future.h>
#include <folly/futures/Promise-inl.h>