aleph
aleph copied to clipboard
Improve wrap-future
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
.isDonefrom.isSuccessinwrap-future - [ ] If
.isDone, choose between returning success- and error-deferreds based on the future's status. For consistency, we can reuse theoperation-completehandler, 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-classloaderin particular