Avoid iterating over all sockets to remove dead sockets

This commit is contained in:
jiangjianfeng
2025-01-15 09:18:06 +00:00
committed by Tate, Hongliang Tian
parent c4229e3c2f
commit 14f0f5a7b5
6 changed files with 165 additions and 102 deletions

View File

@ -0,0 +1,32 @@
// SPDX-License-Identifier: MPL-2.0
/// Defines a struct representing a boolean value.
///
/// In some cases, it is beneficial to use a struct instead of
/// a plain boolean value to clarify the semantics.
/// This macro provides a convenient way to define a struct
/// that represents a boolean value.
#[macro_export]
macro_rules! define_boolean_value {
(
$(#[$attr:meta])*
$name: ident
) => {
$(#[$attr])*
#[derive(Debug, Clone, Copy)]
pub struct $name(bool);
impl $name {
pub const TRUE: Self = Self(true);
pub const FALSE: Self = Self(false);
}
impl core::ops::Deref for $name {
type Target = bool;
fn deref(&self) -> &Self::Target {
&self.0
}
}
};
}