[SERVER-50659] Design CancelationToken integration with Future types Created: 31/Aug/20  Updated: 02/Feb/21  Resolved: 02/Feb/21

Status: Closed
Project: Core Server
Component/s: Internal Code
Affects Version/s: None
Fix Version/s: None

Type: New Feature Priority: Major - P3
Reporter: Matthew Saltz (Inactive) Assignee: Matthew Saltz (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by SERVER-53587 Integrate CancelationTokens with Futu... Closed
Sprint: Service Arch 2021-02-08
Participants:
Story Points: 2

 Description   

This ticket is to design the following functionality:

  • Add ability to do asynchronous, interruptible waits on a future using
    CancelationTokens
  • Add ability to do synchronous, interruptible waits on a future using
    CancelationTokens
  • Add ability to cancel a future chain using CancelationTokens


 Comments   
Comment by Matthew Saltz (Inactive) [ 02/Feb/21 ]

Results of design:

  • Asynchronous: Add a new function withCancelation that takes a future and a CancelationToken. Example usage:

     
        withCancelation(std::move(future), cancelToken)
           .then([] (Result x) { /* handle future completing first */ } )
           .onError<ErrorCodes::CallbackCanceled>([](Status s) { /* handle cancelation happening first */ });
    

  • Synchronous: You can just use withCancelation(...).get();
  • Chain:
  • For ExecutorFutures, make a CancelableExecutor that inherits from OutOfLineExecutor
  • For raw Futures, users will have to manually assert that a token isn't canceled inside each continuation
Comment by Matthew Saltz (Inactive) [ 19/Nov/20 ]

Complexity estimate depends a lot on the final solution

Generated at Thu Feb 08 05:23:14 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.