actix / actix-net

A collection of lower-level libraries for composable network services.
https://actix.rs
Apache License 2.0
706 stars 345 forks source link

Change with_tokio_rt to accept Arc<Runtime>. #599

Open gz opened 1 week ago

gz commented 1 week ago

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:

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 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.

robjtede commented 5 days ago

To avoid breaks we could add a new method for this.