fix deprecated Promise::setException()
authorJames Sedgwick <jsedgwick@fb.com>
Wed, 28 Jan 2015 21:55:45 +0000 (13:55 -0800)
committerwoo <woo@fb.com>
Mon, 2 Feb 2015 21:14:14 +0000 (13:14 -0800)
Summary: should have been using fulfilTry anyways. and fulfilTry needs to take the Try by value so fix that too

Test Plan: unit

Reviewed By: hans@fb.com

Subscribers: fugalh, folly-diffs@, jsedgwick

FB internal diff: D1808923

Tasks: 6098987

Signature: t1:1808923:1422478981:d4b9727394339c996ebccb7841b94e0c7b2bffb4

folly/futures/Promise-inl.h
folly/futures/Promise.h
folly/wangle/channel/OutputBufferingHandler.h

index 94775a92713cc765666ca8f48bc5c399e2b17418..b347486a4faa0d10999e3d852462bb98fbb68985 100644 (file)
@@ -107,7 +107,7 @@ void Promise<T>::setInterruptHandler(
 }
 
 template <class T>
-void Promise<T>::fulfilTry(Try<T>&& t) {
+void Promise<T>::fulfilTry(Try<T> t) {
   throwIfFulfilled();
   core_->setResult(std::move(t));
 }
index 192b1a79d48f5fef2cd250fb1a8366d102d277f7..1412577ff58ee79f04281b2fed82be34b519d0f3 100644 (file)
@@ -77,7 +77,7 @@ public:
   template <class M>
   void setValue(M&& value);
 
-  void fulfilTry(Try<T>&& t);
+  void fulfilTry(Try<T> t);
 
   /** Fulfil this Promise with the result of a function that takes no
     arguments and returns something implicitly convertible to T.
index 06a053d76175e5a7557f91807c3bf51a44696fa4..80221f2e10b52a72878115f14a87d35c494c54a9 100644 (file)
@@ -56,16 +56,9 @@ class OutputBufferingHandler : public BytesToBytesHandler,
 
   void runLoopCallback() noexcept override {
     MoveWrapper<std::vector<Promise<void>>> promises(std::move(promises_));
-    ctx_->fireWrite(std::move(sends_)).then([promises](Try<void>&& t) mutable {
-      try {
-        t.throwIfFailed();
-        for (auto& p : *promises) {
-          p.setValue();
-        }
-      } catch (...) {
-        for (auto& p : *promises) {
-          p.setException(std::current_exception());
-        }
+    ctx_->fireWrite(std::move(sends_)).then([promises](Try<void> t) mutable {
+      for (auto& p : *promises) {
+        p.fulfilTry(t);
       }
     });
   }