Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 45 additions & 29 deletions core/src/common/macros.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
/// Check <https://www.rustwiki.org.cn/en/reference/introduction.html> for help information.

/// Constructs an event at the trace level.
#[allow(unused_macros)]
#[macro_export]
Expand Down Expand Up @@ -66,8 +68,8 @@ macro_rules! impl_display_by_debug {
impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? std::fmt::Display
for $struct_name$(<$($generic1),+>)?
where
$($($generic2 $( : $trait_tt3 $( + $trait_tt4)*)?),+,)?
$struct_name$(<$($generic1),+>)?: std::fmt::Debug,
$($($generic2 $( : $trait_tt3 $( + $trait_tt4)*)?),+,)?
{
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
std::fmt::Debug::fmt(self, f)
Expand All @@ -83,19 +85,14 @@ macro_rules! impl_display_by_debug {
macro_rules! impl_current_for {
(
$name:ident,
$struct_name:ident$(<$($generic1:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?
$(where $(
$generic2:tt $( : $trait_tt3: tt $( + $trait_tt4: tt)*)?
),+)?
$struct_name:ident$(<$($generic:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?
) => {
thread_local! {
static $name: std::cell::RefCell<std::collections::VecDeque<*const std::ffi::c_void>> =
const { std::cell::RefCell::new(std::collections::VecDeque::new()) };
}

impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? $struct_name$(<$($generic1),+>)?
$(where $($generic2 $( : $trait_tt3 $( + $trait_tt4)*)?),+)?
{
impl$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? $struct_name$(<$($generic),+>)? {
/// Init the current.
pub(crate) fn init_current(current: &Self) {
$name.with(|s| {
Expand Down Expand Up @@ -154,46 +151,65 @@ macro_rules! impl_current_for {
/// Check <https://www.rustwiki.org.cn/en/reference/introduction.html> for help information.
#[macro_export]
macro_rules! impl_for_named {
($struct_name:ident$(<$($generic1:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?
$(where $(
$generic2:tt $( : $trait_tt3: tt $( + $trait_tt4: tt)*)?
),+)?
) => {
impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? Eq
for $struct_name$(<$($generic1),+>)?
{
}
($struct_name:ident$(<$($generic:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?) => {
$crate::impl_ord_for_named!($struct_name$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)?);
$crate::impl_hash_for_named!($struct_name$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)?);
};
}

impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? PartialEq<Self>
for $struct_name$(<$($generic1),+>)?
/// Fast impl `Eq` for `Named` types.
#[macro_export]
macro_rules! impl_eq_for_named {
($struct_name:ident$(<$($generic:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?) => {
impl$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? PartialEq<Self>
for $struct_name$(<$($generic),+>)?
{
fn eq(&self, other: &Self) -> bool {
self.name().eq(other.name())
}
}

impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? Ord
for $struct_name$(<$($generic1),+>)?
impl$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? Eq
for $struct_name$(<$($generic),+>)?
{
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.name().cmp(other.name())
}
}
};
}

impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? PartialOrd<Self>
for $struct_name$(<$($generic1),+>)?
/// Fast impl `Ord` for `Named` types.
#[macro_export]
macro_rules! impl_ord_for_named {
($struct_name:ident$(<$($generic:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?) => {
$crate::impl_eq_for_named!($struct_name$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)?);

impl$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? PartialOrd<Self>
for $struct_name$(<$($generic),+>)?
{
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
Some(self.cmp(other))
}
}

impl$(<$($generic1 $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? std::hash::Hash
for $struct_name$(<$($generic1),+>)?
impl$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? Ord
for $struct_name$(<$($generic),+>)?
{
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.name().cmp(other.name())
}
}
}
}

/// Fast impl `std::hash::Hash` for `Named` types.
#[macro_export]
macro_rules! impl_hash_for_named {
($struct_name:ident$(<$($generic:tt $( : $trait_tt1: tt $( + $trait_tt2: tt)*)?),+>)?) => {
impl$(<$($generic $( : $trait_tt1 $( + $trait_tt2)*)?),+>)? std::hash::Hash
for $struct_name$(<$($generic),+>)?
{
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.name().hash(state)
}
}
};
}
}
3 changes: 0 additions & 3 deletions core/src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ pub(crate) mod macros;
/// `BeanFactory` impls.
pub mod beans;

/// `TimerList` impls.
pub mod timer;

/// Suppose a thread in a work-stealing scheduler is idle and looking for the next task to run. To
/// find an available task, it might do the following:
///
Expand Down
210 changes: 0 additions & 210 deletions core/src/common/timer.rs

This file was deleted.

Loading
Loading