diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6f8bac9..0eeb3eb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -60,8 +60,8 @@ jobs: - name: Run cargo test (with valgrind) run: cargo test -- --test-threads=1 env: - # TODO: use --errors-for-leak-kinds=definite,indirect due to upstream bug (https://github.com/rust-lang/rust/issues/135608) - CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind -v --error-exitcode=1 --error-limit=no --leak-check=full --show-leak-kinds=all --errors-for-leak-kinds=definite,indirect --track-origins=yes --fair-sched=yes + # TODO: ignore possible and reachable leaks due to upstream issue (https://github.com/rust-lang/rust/issues/135608) + CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_RUNNER: valgrind -v --error-exitcode=1 --error-limit=no --leak-check=full --show-leak-kinds=definite,indirect --errors-for-leak-kinds=definite,indirect --track-origins=yes --fair-sched=yes --gen-suppressions=all - name: Run cargo test (with portable-atomic enabled) run: cargo test --features portable-atomic - name: Clone async-executor diff --git a/examples/with-metadata.rs b/examples/with-metadata.rs index 1bd1bc7..7a71f50 100644 --- a/examples/with-metadata.rs +++ b/examples/with-metadata.rs @@ -72,9 +72,7 @@ thread_local! { static QUEUE: RefCell> = RefCell::new(BinaryHeap::new()); } -fn make_future_fn<'a, F>( - future: F, -) -> impl (FnOnce(&'a DurationMetadata) -> MeasureRuntime<'a, F>) { +fn make_future_fn<'a, F>(future: F) -> impl FnOnce(&'a DurationMetadata) -> MeasureRuntime<'a, F> { move |duration_meta| MeasureRuntime { f: future, duration: &duration_meta.inner, diff --git a/src/lib.rs b/src/lib.rs index c8f6702..58b2211 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,6 +36,9 @@ //! //! // Push the task into the queue by invoking its schedule function. //! runnable.schedule(); +//! # let handle = std::thread::spawn(move || { for runnable in receiver { runnable.run(); }}); +//! # smol::future::block_on(task); +//! # handle.join().unwrap(); //! ``` //! //! The [`Runnable`] is used to poll the task's future, and the [`Task`] is used to await its diff --git a/src/runnable.rs b/src/runnable.rs index 17945b2..b6b3957 100644 --- a/src/runnable.rs +++ b/src/runnable.rs @@ -734,6 +734,9 @@ impl Runnable { /// assert_eq!(r.len(), 0); /// runnable.schedule(); /// assert_eq!(r.len(), 1); + /// # let handle = std::thread::spawn(move || { for runnable in r { runnable.run(); }}); + /// # smol::future::block_on(task); + /// # handle.join().unwrap(); /// ``` pub fn schedule(self) { let ptr = self.ptr.as_ptr(); @@ -803,6 +806,9 @@ impl Runnable { /// assert_eq!(r.len(), 0); /// waker.wake(); /// assert_eq!(r.len(), 1); + /// # let handle = std::thread::spawn(move || { for runnable in r { runnable.run(); }}); + /// # smol::future::block_on(task.cancel()); // cancel because the future is future::pending + /// # handle.join().unwrap(); /// ``` pub fn waker(&self) -> Waker { let ptr = self.ptr.as_ptr(); diff --git a/src/state.rs b/src/state.rs index 2fc6cf3..40ed5ca 100644 --- a/src/state.rs +++ b/src/state.rs @@ -55,7 +55,7 @@ pub(crate) const REGISTERING: usize = 1 << 6; /// Set if the awaiter is being notified. /// /// This flag is set when notifying the awaiter. If an awaiter is concurrently registered and -/// notified, whichever side came first will take over the reposibility of resolving the race. +/// notified, whichever side came first will take over the responsibility of resolving the race. pub(crate) const NOTIFYING: usize = 1 << 7; /// A single reference. diff --git a/src/task.rs b/src/task.rs index a3dfd17..700cc60 100644 --- a/src/task.rs +++ b/src/task.rs @@ -237,7 +237,7 @@ impl Task { let mut output = None; // Optimistically assume the `Task` is being detached just after creating the task. - // This is a common case so if the `Task` is datached, the overhead of it is only one + // This is a common case so if the `Task` is detached, the overhead of it is only one // compare-exchange operation. if let Err(mut state) = (*header).state.compare_exchange_weak( SCHEDULED | TASK | REFERENCE,