actix-net icon indicating copy to clipboard operation
actix-net copied to clipboard

Change with_tokio_rt to accept Arc<Runtime>.

Open gz opened this issue 5 months ago • 1 comments

This allows to share tokio runtimes across different sub-systems inside your application.

PR Type

Feature, Refactor

https://github.com/actix/actix-net/issues/580

PR Checklist

Check your PR fulfills the following:

  • [x] Tests for the changes have been added / updated.
  • [x] Documentation comments have been added / updated.
  • [ ] A changelog entry has been made for the appropriate packages.
  • [x] Format code with the latest stable rustfmt

Overview

The current signature of https://docs.rs/actix-rt/latest/actix_rt/struct.System.html#method.with_tokio_rt expects a Runtime. It would be better if I can supply an Arc<Runtime> instead. The reason being that is that in a bigger application we have multiple systems trying to leverage tokio. With the given API I still need to create a separate runtime for actix. Having the same runtime is helpful for better control over CPU resources as there aren't n runtimes competing for CPU time.

FWIW this is a breaking change so if there alternative ways to achieve this I'm happy to give those a try too.

gz avatar Sep 04 '24 22:09 gz