aleph icon indicating copy to clipboard operation
aleph copied to clipboard

Improve wrap-future

Open KingMob opened this issue 3 years ago • 0 comments

This was uncovered in the process of reviewing #608. See my comments there for more.

In short, wrap-future checks .isSuccess on a future, when it really means to check .isDone. If it succeeded, it creates an immediate success-deferred. If not, it attaches handlers. In the case of a failed/canceled future, it does a lot of unnecessary work before immediately invoking the handler: fn thread frame binding, handler object creation, and scheduling the handlers to run (potentially) on another thread. This is also kind of confusing because we're checking the wrong condition.

To do:

  • [ ] Switch to .isDone from .isSuccess in wrap-future
  • [ ] If .isDone, choose between returning success- and error-deferreds based on the future's status. For consistency, we can reuse the operation-complete handler, but add a flag to tell it to use/ignore executors (so we can run it on the current thread)
  • [ ] Verify all tests still work, test-classloader in particular

KingMob avatar Aug 03 '22 06:08 KingMob