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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 1 addition & 3 deletions examples/with-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,7 @@ thread_local! {
static QUEUE: RefCell<BinaryHeap<ByDuration>> = 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,
Expand Down
3 changes: 3 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/runnable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,6 +734,9 @@ impl<M> Runnable<M> {
/// 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();
Expand Down Expand Up @@ -803,6 +806,9 @@ impl<M> Runnable<M> {
/// 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();
Expand Down
2 changes: 1 addition & 1 deletion src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion src/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ impl<T, M> Task<T, M> {
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,
Expand Down