From af4c5c42a3c6e01697cdad4604d2f3873a1e5d91 Mon Sep 17 00:00:00 2001 From: somewheve Date: Sat, 15 Mar 2025 20:21:52 +0800 Subject: [PATCH 1/2] use crossbeam-utils instead of cache-padded --- Cargo.toml | 11 +++-------- core/Cargo.toml | 5 +---- core/src/util/mod.rs | 10 +++++----- core/src/util/spsc.rs | 2 +- log/src/lib.rs | 2 +- 5 files changed, 11 insertions(+), 19 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 361bb02..e07032b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +resolver = "1" members = [ "core", "log", @@ -8,14 +9,8 @@ members = [ [patch.crates-io] flashfunk-core = { path = "./core" } owned-log = { path = "./log" } - -xitca-client = { git = "https://github.com/HFQR/xitca-web.git" } -xitca-http = { git = "https://github.com/HFQR/xitca-web.git" } -xitca-io = { git = "https://github.com/HFQR/xitca-web.git" } -xitca-service = { git = "https://github.com/HFQR/xitca-web.git" } -xitca-unsafe-collection = { git = "https://github.com/HFQR/xitca-web.git" } - -http-ws = { git = "https://github.com/HFQR/xitca-web.git" } +xitca-client = { git = "https://github.com/HFQR/xitca-web/" } +http-ws = { git = "https://github.com/HFQR/xitca-web/" } [profile.release] lto = true diff --git a/core/Cargo.toml b/core/Cargo.toml index 512a1b6..9c40f9f 100755 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -15,11 +15,8 @@ std = ["core_affinity"] async = ["std", "futures-core", "parking"] [dependencies] -cache-padded = "1.1.1" - -# core affinity support +crossbeam-utils = "0.8" core_affinity = { version = "0.8", optional = true } - # async feature support futures-core = { version = "0.3", default-features = false, features = ["alloc"], optional = true } parking = { version = "2", optional = true } diff --git a/core/src/util/mod.rs b/core/src/util/mod.rs index f9011ab..1e0683c 100644 --- a/core/src/util/mod.rs +++ b/core/src/util/mod.rs @@ -8,16 +8,16 @@ pub mod fx_hasher; pub mod no_hasher; pub mod spin; -pub(super) mod pin_to_core { +pub mod pin_to_core { use alloc::vec::Vec; #[cfg(feature = "std")] - pub(crate) type CoreId = core_affinity::CoreId; + pub type CoreId = core_affinity::CoreId; #[cfg(not(feature = "std"))] - pub(crate) struct CoreId; + pub struct CoreId; - pub(crate) fn get_core_ids() -> Vec { + pub fn get_core_ids() -> Vec { #[cfg(feature = "std")] { core_affinity::get_core_ids().unwrap() @@ -29,7 +29,7 @@ pub(super) mod pin_to_core { } } - pub(crate) fn pin_to_core(id: Option) { + pub fn pin_to_core(id: Option) { if let Some(id) = id { #[cfg(feature = "std")] { diff --git a/core/src/util/spsc.rs b/core/src/util/spsc.rs index 0c419b6..74371dc 100644 --- a/core/src/util/spsc.rs +++ b/core/src/util/spsc.rs @@ -11,7 +11,7 @@ use core::{ use alloc::{sync::Arc, vec::Vec}; -use cache_padded::CachePadded; +use crossbeam_utils::CachePadded; /// The inner representation of a single-producer single-consumer queue. struct Inner { diff --git a/log/src/lib.rs b/log/src/lib.rs index 88d2dcc..1821a65 100644 --- a/log/src/lib.rs +++ b/log/src/lib.rs @@ -18,7 +18,7 @@ pub static OWNED_LOGGER: OnceCell> = OnceCell::new(); #[macro_export] macro_rules! log { ($value: expr) => { - ::owned_log::__private::OWNED_LOGGER_LOCAL.with(|logger| logger.log($value)); + ::owned_log::__private::OWNED_LOGGER_LOCAL.with(|logger| logger.log(Box::new($value))); }; } From d0f3fa6c8c591db5e7cfdcd44f06ce71f7cf96b7 Mon Sep 17 00:00:00 2001 From: somewheve Date: Sun, 16 Mar 2025 03:10:21 +0800 Subject: [PATCH 2/2] fix log example error --- examples/src/log.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/src/log.rs b/examples/src/log.rs index 175ecd5..3870f67 100644 --- a/examples/src/log.rs +++ b/examples/src/log.rs @@ -29,7 +29,7 @@ fn main() { } for _ in 0..99 { - owned_log::log!(Box::new(MyValue(1))); + owned_log::log!(MyValue(1)); } let flag = Arc::new(AtomicBool::new(false)); @@ -47,7 +47,7 @@ fn main() { while time < 8 { if flag.swap(false, Ordering::SeqCst) { - let value = Box::new(MyValue(2)) as _; + let value = MyValue(2); let now = std::time::Instant::now(); owned_log::log!(value); total += now.elapsed().as_nanos();