2
0
Fork 0
mirror of https://git.asonix.dog/asonix/pict-rs synced 2024-11-20 11:21:14 +00:00

Add track_caller to sync methods, update streem

This commit is contained in:
asonix 2023-09-10 20:43:51 -04:00
parent b2674f06d0
commit ea75ca24b5
3 changed files with 9 additions and 3 deletions

4
Cargo.lock generated
View file

@ -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",

View file

@ -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"] }

View file

@ -2,22 +2,27 @@ use std::sync::Arc;
use tokio::sync::{Notify, Semaphore};
#[track_caller]
pub(crate) fn channel<T>(bound: usize) -> (flume::Sender<T>, flume::Receiver<T>) {
tracing::trace_span!(parent: None, "make channel").in_scope(|| flume::bounded(bound))
}
#[track_caller]
pub(crate) fn notify() -> Arc<Notify> {
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<F>(future: F) -> actix_rt::task::JoinHandle<F::Output>
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<F, Out>(function: F) -> actix_rt::task::JoinHandle<Out>
where
F: FnOnce() -> Out + Send + 'static,