mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Avoid iterating over all sockets to remove dead sockets
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
c4229e3c2f
commit
14f0f5a7b5
32
kernel/libs/aster-bigtcp/src/boolean_value.rs
Normal file
32
kernel/libs/aster-bigtcp/src/boolean_value.rs
Normal 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
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user