Replace Later in tcc
authorHans Fugal <fugalh@fb.com>
Wed, 3 Dec 2014 17:38:47 +0000 (09:38 -0800)
committerDave Watson <davejwatson@fb.com>
Thu, 11 Dec 2014 15:59:14 +0000 (07:59 -0800)
Summary:
s/`sendAsyncLater`/`sendAsyncVia`/ and change it to return a cold future with equivalent semantics. We have to call `via` twice in the implementation—once to gate the result and again to make sure the caller will get a future that executes in that executor's context also.

NB this is a slight semantic change - if the executor is, say, a threadpool then now it will go through the threadpool queue (and maybe execute in two different threads) whereas before the whole later chain would execute in the same thread. I don't *think* this is a problem, but something to think about.

Test Plan:
stuff we fbconfig'd builds
contbuild
unit tests
thinking really hard

Reviewed By: hannesr@fb.com

Subscribers: trunkagent, fbcode-common-diffs@, net-systems@, ldbrandy, hannesr, fugalh, zhuohuang, exa, watashi, smarlow, akr, bnitka, jcoens, darshan, njormrod, anfarmer, folly-diffs@

FB internal diff: D1644012

Tasks: 5409538

Signature: t1:1644012:1417625401:99b1b7df6de4cfcdd945eed7104d4c82e8c0b78f

folly/wangle/Future.h

index e169865b75f286d898d6293b581733612bc83f46..9c19d37f39ba6bf13f63ecfa2a59b13762d05e3b 100644 (file)
@@ -308,11 +308,21 @@ class Future {
   /// by then), and it is active (active by default).
   ///
   /// Inactive Futures will activate upon destruction.
-  void activate() {
+  Future<T>& activate() & {
     core_->activate();
+    return *this;
   }
-  void deactivate() {
+  Future<T>& deactivate() & {
     core_->deactivate();
+    return *this;
+  }
+  Future<T> activate() && {
+    core_->activate();
+    return std::move(*this);
+  }
+  Future<T> deactivate() && {
+    core_->deactivate();
+    return std::move(*this);
   }
   bool isActive() {
     return core_->isActive();