From ea75ca24b557b01ad95bf1fa62ed3792725e4c87 Mon Sep 17 00:00:00 2001 From: asonix Date: Sun, 10 Sep 2023 20:43:51 -0400 Subject: [PATCH] Add track_caller to sync methods, update streem --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- src/sync.rs | 6 ++++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a3f9cf0..8a9f367 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2649,9 +2649,9 @@ checksum = "7f11d35dae9818c4313649da4a97c8329e29357a7fe584526c1d78f5b63ef836" [[package]] name = "streem" -version = "0.1.1" +version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "641396a5ae90767cb12d21832444ab760841ee887717d802b2c456c4f8199114" +checksum = "6c8b0c8184b0fe05b37dd75d66205195cd57563c6c87cb92134a025a34a6ab34" dependencies = [ "futures-core", "pin-project-lite", diff --git a/Cargo.toml b/Cargo.toml index 084d65a..753b468 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ serde_urlencoded = "0.7.1" sha2 = "0.10.0" sled = { version = "0.34.7" } storage-path-generator = "0.1.0" -streem = "0.1.1" +streem = "0.2.0" thiserror = "1.0" time = { version = "0.3.0", features = ["serde", "serde-well-known"] } tokio = { version = "1", features = ["full", "tracing"] } diff --git a/src/sync.rs b/src/sync.rs index 3111daf..10cc861 100644 --- a/src/sync.rs +++ b/src/sync.rs @@ -2,22 +2,27 @@ use std::sync::Arc; use tokio::sync::{Notify, Semaphore}; +#[track_caller] pub(crate) fn channel(bound: usize) -> (flume::Sender, flume::Receiver) { tracing::trace_span!(parent: None, "make channel").in_scope(|| flume::bounded(bound)) } +#[track_caller] pub(crate) fn notify() -> Arc { Arc::new(bare_notify()) } +#[track_caller] pub(crate) fn bare_notify() -> Notify { tracing::trace_span!(parent: None, "make notifier").in_scope(Notify::new) } +#[track_caller] pub(crate) fn bare_semaphore(permits: usize) -> Semaphore { tracing::trace_span!(parent: None, "make semaphore").in_scope(|| Semaphore::new(permits)) } +#[track_caller] pub(crate) fn spawn(future: F) -> actix_rt::task::JoinHandle where F: std::future::Future + 'static, @@ -26,6 +31,7 @@ where tracing::trace_span!(parent: None, "spawn task").in_scope(|| actix_rt::spawn(future)) } +#[track_caller] pub(crate) fn spawn_blocking(function: F) -> actix_rt::task::JoinHandle where F: FnOnce() -> Out + Send + 'static,