use previous Executor after delayed
authorAlex Yarmula <ayarmula@fb.com>
Thu, 6 Oct 2016 14:21:22 +0000 (07:21 -0700)
committerFacebook Github Bot <facebook-github-bot-bot@fb.com>
Thu, 6 Oct 2016 14:23:30 +0000 (07:23 -0700)
commit67fcea204a38d79224d19aeab682420f2397510e
tree171bad8aa29cdab317cd2b1ae99277db484b7c2d
parent008075cac3e70a06a7d15c7f808638685462e289
use previous Executor after delayed

Summary:
When `delayed` is called on the Future, the underlying `futures::sleep` call runs on a timer thread, and the resulting callback is called on the same thread. Therefore, in the following sequence:

  f.via(&someExecutor).within(one_ms).then([&]() { /* [1] */ })

The code in [1] is not running in someExecutor. This can cause confusion by users of the library who expect the initial `via` to be sticky.

This change returns to the prior `Executor` after `delayed` is finished.

Reviewed By: yfeldblum

Differential Revision: D3979179

fbshipit-source-id: 936ff5626e8ac377ffb15babf573349466984e3a
folly/futures/Future-inl.h
folly/futures/test/TimekeeperTest.cpp