added pub option

This commit is contained in:
mamoniot 2023-03-21 08:25:15 -04:00
parent 984782d779
commit c2125db444
No known key found for this signature in database
GPG key ID: ADCCDBBE0E3D3B3B

View file

@ -348,7 +348,7 @@ unsafe impl<T, OriginPool: StaticPool<T, L>, const L: usize> Sync for PoolArcSwa
/// ``` /// ```
/// use zerotier_utils::arc_pool::{Pool, StaticPool, static_pool}; /// use zerotier_utils::arc_pool::{Pool, StaticPool, static_pool};
/// ///
/// static_pool!(StaticPool MyPools { /// static_pool!(pub StaticPool MyPools {
/// Pool<u32>, Pool<&u32, 12> /// Pool<u32>, Pool<&u32, 12>
/// }); /// });
/// ///
@ -384,6 +384,30 @@ macro_rules! __static_pool__ {
} }
)* )*
}; };
(pub $m:ident $s:ident { $($($p:ident)::+<$t:ty$(, $l:tt)?>),+ $(,)?}) => {
pub struct $s {}
$(
impl $m<$t$(, $l)?> for $s {
#[inline(always)]
unsafe fn get_static_pool() -> *const () {
static POOL: $($p)::+<$t$(, $l)?> = $($p)::+::new();
(&POOL as *const $($p)::+<$t$(, $l)?>).cast()
}
}
)*
};
(pub $m:ident::$n:ident $s:ident { $($($p:ident)::+<$t:ty$(, $l:tt)?>),+ $(,)?}) => {
pub struct $s {}
$(
impl $m::$n<$t$(, $l)?> for $s {
#[inline(always)]
unsafe fn get_static_pool() -> *const () {
static POOL: $($p)::+<$t$(, $l)?> = $($p)::+::new();
(&POOL as *const $($p)::+<$t$(, $l)?>).cast()
}
}
)*
};
} }
pub use __static_pool__ as static_pool; pub use __static_pool__ as static_pool;