From 6fdeaebacf7f89fd40a3c866a7f60eee66a805d5 Mon Sep 17 00:00:00 2001 From: Hans Fugal Date: Wed, 3 Dec 2014 09:38:47 -0800 Subject: [PATCH] Replace Later in tcc MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/folly/wangle/Future.h b/folly/wangle/Future.h index e169865b..9c19d37f 100644 --- a/folly/wangle/Future.h +++ b/folly/wangle/Future.h @@ -308,11 +308,21 @@ class Future { /// by then), and it is active (active by default). /// /// Inactive Futures will activate upon destruction. - void activate() { + Future& activate() & { core_->activate(); + return *this; } - void deactivate() { + Future& deactivate() & { core_->deactivate(); + return *this; + } + Future activate() && { + core_->activate(); + return std::move(*this); + } + Future deactivate() && { + core_->deactivate(); + return std::move(*this); } bool isActive() { return core_->isActive(); -- 2.34.1