Future: improve test with task discarding executors
authorSven Over <over@fb.com>
Fri, 5 May 2017 16:12:51 +0000 (09:12 -0700)
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>
Fri, 5 May 2017 16:28:32 +0000 (09:28 -0700)
commit3703b1b00456c1ebf84937e579dca392905ab098
tree0024dab779379d3dd1d412b25be8d8f0dbbd18b0
parentc484e2caa8fcbc9b3d362b25e981122ba0497544
Future: improve test with task discarding executors

Summary:
We have tests that check that the Future implementation deals
cleanly with executors discarding tasks. The existing tests destroy
the tasks immediately when they are passed to Executor::add. This
diff adds corresponding tests for the scenario where the task is
not destroyed right away, but after the call to Future::then has
completed.

This diff also adds a mechanism to detect that the passed callback
function is actually destroyed. We have tested already that the
promise returned by folly::then will be set to a BrokenPromise
exception when the executor discards the task. However, the task
passed to the executor is not only the callback we pass to
folly::then, as the Future implementation wraps it with some code
that stores the return value in a Promise. Existing tests check
that this Promise is destroyed. The added mechanism in this diff
checks that the orignal callback function itself gets destroyed.

Reviewed By: Krigpl

Differential Revision: D5002100

fbshipit-source-id: 4155f61b075d9fe8d1869ad229f4d350571ff4c6
folly/futures/test/ViaTest.cpp