From: James Sedgwick Date: Wed, 28 Jan 2015 21:55:45 +0000 (-0800) Subject: fix deprecated Promise::setException() X-Git-Tag: v0.23.0~10 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=7b5d03d60aaeeb217fb33d3d3f9be24cc3d0b6b9;p=folly.git fix deprecated Promise::setException() 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 --- diff --git a/folly/futures/Promise-inl.h b/folly/futures/Promise-inl.h index 94775a92..b347486a 100644 --- a/folly/futures/Promise-inl.h +++ b/folly/futures/Promise-inl.h @@ -107,7 +107,7 @@ void Promise::setInterruptHandler( } template -void Promise::fulfilTry(Try&& t) { +void Promise::fulfilTry(Try t) { throwIfFulfilled(); core_->setResult(std::move(t)); } diff --git a/folly/futures/Promise.h b/folly/futures/Promise.h index 192b1a79..1412577f 100644 --- a/folly/futures/Promise.h +++ b/folly/futures/Promise.h @@ -77,7 +77,7 @@ public: template void setValue(M&& value); - void fulfilTry(Try&& t); + void fulfilTry(Try t); /** Fulfil this Promise with the result of a function that takes no arguments and returns something implicitly convertible to T. diff --git a/folly/wangle/channel/OutputBufferingHandler.h b/folly/wangle/channel/OutputBufferingHandler.h index 06a053d7..80221f2e 100644 --- a/folly/wangle/channel/OutputBufferingHandler.h +++ b/folly/wangle/channel/OutputBufferingHandler.h @@ -56,16 +56,9 @@ class OutputBufferingHandler : public BytesToBytesHandler, void runLoopCallback() noexcept override { MoveWrapper>> promises(std::move(promises_)); - ctx_->fireWrite(std::move(sends_)).then([promises](Try&& 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 t) mutable { + for (auto& p : *promises) { + p.fulfilTry(t); } }); }