clj-commons / aleph

Asynchronous streaming communication for Clojure - web server, web client, and raw TCP/UDP
http://aleph.io
MIT License
2.54k stars 241 forks source link

Improve short-circuiting behavior of `wrap-future` #622

Closed DerGuteMoritz closed 2 years ago

DerGuteMoritz commented 2 years ago

If the Netty future passed to wrap-future is already done, resolve the deferred result immediately. This short-circuits the Netty future listener indirection and all the overhead it involves in such a situation.

Note that this optimization was already partially implemented, namely for the success case. This patch merely generelizes it to all "done" cases.

Fixes #614.