Really fix the clang warning in Format-inl.h
[folly.git] / folly / wangle / Promise-inl.h
index 04cc9a3f84ca62fb639d7cdeabe864312745a7dd..68d696411f184d37640a0024fabdfcc3a520564c 100644 (file)
 #include <thread>
 
 #include <folly/wangle/WangleException.h>
-#include <folly/wangle/detail/State.h>
+#include <folly/wangle/detail/Core.h>
 
 namespace folly { namespace wangle {
 
 template <class T>
-Promise<T>::Promise() : retrieved_(false), state_(new detail::State<T>())
+Promise<T>::Promise() : retrieved_(false), core_(new detail::Core<T>())
 {}
 
 template <class T>
-Promise<T>::Promise(Promise<T>&& other) : state_(nullptr) {
+Promise<T>::Promise(Promise<T>&& other) : core_(nullptr) {
   *this = std::move(other);
 }
 
 template <class T>
 Promise<T>& Promise<T>::operator=(Promise<T>&& other) {
-  std::swap(state_, other.state_);
+  std::swap(core_, other.core_);
   std::swap(retrieved_, other.retrieved_);
   return *this;
 }
 
 template <class T>
 void Promise<T>::throwIfFulfilled() {
-  if (!state_)
+  if (!core_)
     throw NoState();
-  if (state_->ready())
+  if (core_->ready())
     throw PromiseAlreadySatisfied();
 }
 
@@ -61,11 +61,11 @@ Promise<T>::~Promise() {
 
 template <class T>
 void Promise<T>::detach() {
-  if (state_) {
+  if (core_) {
     if (!retrieved_)
-      state_->detachFuture();
-    state_->detachPromise();
-    state_ = nullptr;
+      core_->detachFuture();
+    core_->detachPromise();
+    core_ = nullptr;
   }
 }
 
@@ -73,7 +73,7 @@ template <class T>
 Future<T> Promise<T>::getFuture() {
   throwIfRetrieved();
   retrieved_ = true;
-  return Future<T>(state_);
+  return Future<T>(core_);
 }
 
 template <class T>
@@ -85,13 +85,19 @@ void Promise<T>::setException(E const& e) {
 template <class T>
 void Promise<T>::setException(std::exception_ptr const& e) {
   throwIfFulfilled();
-  state_->setException(e);
+  core_->setResult(Try<T>(e));
+}
+
+template <class T>
+void Promise<T>::setInterruptHandler(
+  std::function<void(std::exception_ptr const&)> fn) {
+  core_->setInterruptHandler(std::move(fn));
 }
 
 template <class T>
 void Promise<T>::fulfilTry(Try<T>&& t) {
   throwIfFulfilled();
-  state_->fulfil(std::move(t));
+  core_->setResult(std::move(t));
 }
 
 template <class T>