• Hans Fugal's avatar
    (futures) Make executors sticky · fc6f0a5f
    Hans Fugal authored
    Summary:
    Instead of returning a deactivated future, have `via` just set the executor. Propagate the executor from `then`. This fixes the `via().get()` problem, and has semantics similar to before for `via().then().then()`.
    
    However, the semantics are now slightly different - each `then` goes back through the executor. This adds some overhead and tweaks the semantics (e.g. if the executor is a threadpool it might execute subsequent `then`s in another thread). However, with `futures::chain` recently introduced, and any other convenience methods that you can dream up and make a case for, we can reasonably get the old once-through-the-executor behavior when performance or other concerns demand it. e.g. `via().then(futures::chain(a, b, c))`.
    
    Test Plan: unit tests
    
    Reviewed By: hannesr@fb.com
    
    Subscribers: zeus-diffs@, mmandal, steveo, rituraj, trunkagent, exa, folly-diffs@, yfeldblum, jsedgwick, davejwatson
    
    FB internal diff: D1839691
    
    Tasks: 6048744
    
    Signature: t1:1839691:1424397180:ca0b0ea7b3867769ab8abd254a510059df67011e
    fc6f0a5f
Future-inl.h 20.8 KB