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
I think it would be preferable to change the docs to state that the channel's capacity will be at leastcapacity, rather than publicly committing to power of two capacities. The bitmask is an internal implementation detail, and if it's possible to document the behavior clearly in a way that does not commit to maintaining that internal implementation detail forever, that's probably better.
The vector will be able to hold at least capacity elements without reallocating. This method is allowed to allocate for more elements than capacity. If capacity is 0, the vector will not allocate.
...
If it is important to know the exact allocated capacity of a Vec, always use the capacity method after construction.
The broadcast channel docs could probably use similar language.
Description
tokio::sync::broadcast
documentation states that thecapacity
parameter is an upper bound on the number of values the channel may retain at any given time.But when creating the channel, this
capacity
is actually rounded up to the nearest power of two - thus the constraint thatcapacity <= usize::MAX / 2
onchannel()
Solution
I guess we want to either
capacity
, (but then the constraint ofcapacity <= usize::MAX / 2
is not clear)For context, I came across this messing around with the example code:
The text was updated successfully, but these errors were encountered: