You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, if a user wants to create an actor with non-default (normal and/or high-priority) inbox capacities, they need to either create their addr first using Addr::with_capacity() or spawn them using system.prepare[_fn]().with_capacity().
However, the actors themselves often have enough information to determine their best (or at least good default) inbox capacities, so let's allow them doing so! This has a potential to noticeably simplify "actor system setup" codebase sections.
Addr already has actor generic type parameter, so it can access static methods and constants defined on it in its constructor.
Implementation-wise this would be about adding either an associated constant to Actor trait to determine default capacity (if Rust allows having defaults for associated constants), or a static method (without &self) to the Actor trait with default implementation. In both cases we likely don't want to add any more mandatory items that Actors need to implement. Change impl Default for Addr to use these method(s)/constant(s).
Another thing left to bikeshed is whether this should be a single constant/method returning Capacity, or 2 separate methods/constants for normal, high-prio capacities returning usize. Notice the DEFAULT_CHANNEL_CAPACITY constant is not currently public.
Currently, if a user wants to create an actor with non-default (normal and/or high-priority) inbox capacities, they need to either create their
addr
first usingAddr::with_capacity()
or spawn them usingsystem.prepare[_fn]().with_capacity()
.However, the actors themselves often have enough information to determine their best (or at least good default) inbox capacities, so let's allow them doing so! This has a potential to noticeably simplify "actor system setup" codebase sections.
Addr
already has actor generic type parameter, so it can access static methods and constants defined on it in its constructor.Implementation-wise this would be about adding either an associated constant to
Actor
trait to determine default capacity (if Rust allows having defaults for associated constants), or a static method (without&self
) to theActor
trait with default implementation. In both cases we likely don't want to add any more mandatory items that Actors need to implement. Changeimpl Default for Addr
to use these method(s)/constant(s).Another thing left to bikeshed is whether this should be a single constant/method returning
Capacity
, or 2 separate methods/constants for normal, high-prio capacities returningusize
. Notice theDEFAULT_CHANNEL_CAPACITY
constant is not currently public.CC @bschwind @skywhale @PabloMansanet.
The text was updated successfully, but these errors were encountered: