projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
A thread-per-task executor
[folly.git]
/
folly
/
futures
/
Promise.h
diff --git
a/folly/futures/Promise.h
b/folly/futures/Promise.h
index e39ea57f0d2ff9e06ae11547ee9a7994666f109b..379ad5d6fdc2b5c273a1cfeb5ff44110936370d6 100644
(file)
--- a/
folly/futures/Promise.h
+++ b/
folly/futures/Promise.h
@@
-1,5
+1,5
@@
/*
/*
- * Copyright 201
5
Facebook, Inc.
+ * Copyright 201
6
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.
@@
-16,7
+16,7
@@
#pragma once
#pragma once
-#include <folly/
futures/Deprecated
.h>
+#include <folly/
Portability
.h>
#include <folly/futures/Try.h>
#include <functional>
#include <folly/futures/Try.h>
#include <functional>
@@
-53,7
+53,8
@@
public:
p.setException(std::current_exception());
}
*/
p.setException(std::current_exception());
}
*/
- void setException(std::exception_ptr const&) DEPRECATED;
+ FOLLY_DEPRECATED("use setException(exception_wrapper)")
+ void setException(std::exception_ptr const&);
/** Fulfill the Promise with an exception type E, which can be passed to
std::make_exception_ptr(). Useful for originating exceptions. If you
/** Fulfill the Promise with an exception type E, which can be passed to
std::make_exception_ptr(). Useful for originating exceptions. If you
@@
-70,14
+71,18
@@
public:
/// handled.
void setInterruptHandler(std::function<void(exception_wrapper const&)>);
/// handled.
void setInterruptHandler(std::function<void(exception_wrapper const&)>);
- /** Fulfill this Promise (only for Promise<void>) */
- void setValue();
+ /// Sugar to fulfill this Promise<Unit>
+ template <class B = T>
+ typename std::enable_if<std::is_same<Unit, B>::value, void>::type
+ setValue() {
+ setTry(Try<T>(T()));
+ }
/** Set the value (use perfect forwarding for both move and copy) */
template <class M>
void setValue(M&& value);
/** Set the value (use perfect forwarding for both move and copy) */
template <class M>
void setValue(M&& value);
- void setTry(Try<T> t);
+ void setTry(Try<T>
&&
t);
/** Fulfill this Promise with the result of a function that takes no
arguments and returns something implicitly convertible to T.
/** Fulfill this Promise with the result of a function that takes no
arguments and returns something implicitly convertible to T.
@@
-88,8
+93,11
@@
public:
template <class F>
void setWith(F&& func);
template <class F>
void setWith(F&& func);
+ bool isFulfilled();
+
private:
typedef typename Future<T>::corePtr corePtr;
private:
typedef typename Future<T>::corePtr corePtr;
+ template <class> friend class Future;
// Whether the Future has been retrieved (a one-time operation).
bool retrieved_;
// Whether the Future has been retrieved (a one-time operation).
bool retrieved_;