pub enum UdpStreamParallelism {
Auto,
Specific(NonZeroUsize),
}Expand description
Determines how many parallel readers or writer sockets should be bound in ConnectedUdpStream.
Each UDP socket is bound with SO_REUSEADDR and SO_REUSEPORT to facilitate parallel processing
of send and/or receive operations.
NOTE: This is a Linux-specific optimization, and it will have no effect on other systems.
- If some
Specificvaluen> 0 is given, theConnectedUdpStreamwill bindnsockets. - If
Autois given, the number of sockets bound byConnectedUdpStreamis determined bystd::thread::available_parallelism.
The default is Specific(1).
Always use into_num_tasks or
split_evenly_with to determine the correct number of sockets to spawn.
Variants§
Auto
Bind as many sender or receiver sockets as given by std::thread::available_parallelism.
Specific(NonZeroUsize)
Bind a specific number of sender or receiver sockets.
Implementations§
Source§impl UdpStreamParallelism
impl UdpStreamParallelism
Sourcepub fn split_evenly_with(self, other: UdpStreamParallelism) -> (usize, usize)
pub fn split_evenly_with(self, other: UdpStreamParallelism) -> (usize, usize)
Returns the number of sockets for this and the other instance
when they evenly split the available CPU parallelism.
Sourcepub fn into_num_tasks(self) -> usize
pub fn into_num_tasks(self) -> usize
Calculates the actual number of tasks for this instance.
The returned value is never more than the maximum available CPU parallelism.
Trait Implementations§
Source§impl Clone for UdpStreamParallelism
impl Clone for UdpStreamParallelism
Source§fn clone(&self) -> UdpStreamParallelism
fn clone(&self) -> UdpStreamParallelism
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UdpStreamParallelism
impl Debug for UdpStreamParallelism
Source§impl Default for UdpStreamParallelism
impl Default for UdpStreamParallelism
Source§impl From<usize> for UdpStreamParallelism
impl From<usize> for UdpStreamParallelism
Source§impl PartialEq for UdpStreamParallelism
impl PartialEq for UdpStreamParallelism
impl Copy for UdpStreamParallelism
impl Eq for UdpStreamParallelism
impl StructuralPartialEq for UdpStreamParallelism
Auto Trait Implementations§
impl Freeze for UdpStreamParallelism
impl RefUnwindSafe for UdpStreamParallelism
impl Send for UdpStreamParallelism
impl Sync for UdpStreamParallelism
impl Unpin for UdpStreamParallelism
impl UnwindSafe for UdpStreamParallelism
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more