extend future api with Future<T>::poll
authorJeroen Vaelen <jeroenv@fb.com>
Fri, 13 Mar 2015 21:10:55 +0000 (14:10 -0700)
committerAndre Azevedo <aap@fb.com>
Wed, 18 Mar 2015 03:18:46 +0000 (20:18 -0700)
commit66047c6ab0f4b6cbd083d76021cfafef3f8e4c7a
tree0c4dc7ca92feabcaeae5982f6e8ec94cea3fa44a
parentaae7c5b3cd843fcd57cedf2558204c7c994353e8
extend future api with Future<T>::poll

Summary:
Added folly::Future<T>::poll() function with the following semantics:
poll() checks if the promise has been fulfilled, if so it will extract the value of the resulting Try<T> to construct a new Try<T> that is wrapped in an Optional<Try<T>>. If the promise has not been fulfilled an empty Optional is returned.

Test Plan: Added two tests to SugarTest.cpp: one where the promise has been fulfilled and one where it hasn't.

Reviewed By: hannesr@fb.com

Subscribers: trunkagent, folly-diffs@, jsedgwick, arturg, yfeldblum

FB internal diff: D1909480

Tasks: 6166875

Signature: t1:1909480:1426280247:6b239c0f1a15c25ce7664afb4bfb3899993c5775
folly/futures/Future-inl.h
folly/futures/Future.h
folly/futures/test/SugarTest.cpp [new file with mode: 0644]