X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=folly%2Ffutures%2FPromise.h;h=905ce5dd7eb9a4a1d23864aed407381920ad3728;hb=f2925b23df8d85ebca72d62a69f1282528c086de;hp=b18f59b2808d59f5b365c6f890c5f87e3489ee43;hpb=a56a988a8cd07c7e3250f27594b8f92c9274b30d;p=folly.git diff --git a/folly/futures/Promise.h b/folly/futures/Promise.h index b18f59b2..905ce5dd 100644 --- a/folly/futures/Promise.h +++ b/folly/futures/Promise.h @@ -1,5 +1,5 @@ /* - * Copyright 2016 Facebook, Inc. + * Copyright 2017 Facebook, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,11 +23,23 @@ namespace folly { // forward declaration +template +class SemiFuture; template class Future; +namespace futures { +namespace detail { +struct EmptyConstruct {}; +template +class CoreCallbackState; +} // namespace detail +} // namespace futures + template class Promise { -public: + public: + static Promise makeEmpty() noexcept; // equivalent to moved-from + Promise(); ~Promise(); @@ -93,11 +105,15 @@ public: template void setWith(F&& func); - bool isFulfilled(); + bool isFulfilled() const noexcept; -private: + private: typedef typename Future::corePtr corePtr; + template + friend class SemiFuture; template friend class Future; + template + friend class futures::detail::CoreCallbackState; // Whether the Future has been retrieved (a one-time operation). bool retrieved_; @@ -105,12 +121,14 @@ private: // shared core state object corePtr core_; + explicit Promise(futures::detail::EmptyConstruct) noexcept; + void throwIfFulfilled(); void throwIfRetrieved(); void detach(); }; -} +} // namespace folly #include #include