Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add async <--> blocking "bridge" Fns to async channel #91

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from
Draft
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
25 changes: 19 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
[workspace]
members = [
".",
"bench"
]
members = [".", "bench"]

[package]
name = "thingbuf"
Expand Down Expand Up @@ -31,13 +28,22 @@ pin-project = "1"
parking_lot = { version = "0.12", optional = true, default-features = false }

[dev-dependencies]
tokio = { version = "1.14.0", features = ["rt", "rt-multi-thread", "macros", "sync"] }
tokio = { version = "1.14.0", features = [
"rt",
"rt-multi-thread",
"macros",
"sync",
"time",
] }
# So that we can use `poll_fn` in tests.
futures-util = { version = "0.3", default-features = false }

[target.'cfg(loom)'.dev-dependencies]
loom = { version = "0.5.6", features = ["checkpoint", "futures"] }
tracing-subscriber = { version = "0.3", default-features = false, features = ["std", "fmt"] }
tracing-subscriber = { version = "0.3", default-features = false, features = [
"std",
"fmt",
] }
tracing = { version = "0.1", default-features = false, features = ["std"] }

# Custom profile for Loom tests: enable release optimizations so that the loom
Expand All @@ -53,3 +59,10 @@ loom = { git = "https://github.com/tokio-rs/loom", rev = "a93bf2390e0fcfdb7c5899
[package.metadata.docs.rs]
all-features = true
rustdoc-args = ["--cfg", "docsrs"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = [
'cfg(loom)',
'cfg(thingbuf_trace)',
'cfg(ci_skip_slow_models)',
] }
11 changes: 6 additions & 5 deletions bin/loom
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,16 @@ cd "$(dirname "$0")"/..
TESTCMD=(test)

# if cargo nextest is installed, use it instead!
if cargo list | grep -q "nextest"; then
TESTCMD=(nextest run --cargo-profile loom)
if cargo --list | grep -q "nextest"; then
TESTCMD=(nextest run --cargo-profile loom)
fi

TESTCMD+=(--profile loom --lib)
# pass through args
TESTCMD+=(${@})

RUSTFLAGS="--cfg loom ${RUSTFLAGS:-}" \
LOOM_LOG="${LOOM_LOG:-info}" \
LOOM_MAX_PREEMPTIONS="${LOOM_MAX_PREEMPTIONS:-2}" \
cargo ${TESTCMD[@]}
LOOM_LOG="${LOOM_LOG:-info}" \
LOOM_MAX_PREEMPTIONS="${LOOM_MAX_PREEMPTIONS:-2}" \
cargo ${TESTCMD[@]}

2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ mod macros;
mod loom;
pub mod mpsc;
pub mod recycling;
#[cfg(feature = "std")]
mod thread_waker;
mod util;
mod wait;

Expand Down
4 changes: 2 additions & 2 deletions src/loom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod inner {
pub use std::sync::atomic::Ordering;
}

pub(crate) use loom::{cell, future, hint, sync, thread};
pub(crate) use loom::{cell, future, hint, sync, thread, thread_local};
use std::{cell::RefCell, fmt::Write};

pub(crate) mod model {
Expand Down Expand Up @@ -214,7 +214,7 @@ mod inner {
pub(crate) use core::sync::atomic;

#[cfg(feature = "std")]
pub use std::thread;
pub use std::{thread, thread_local};

pub(crate) mod hint {
#[inline(always)]
Expand Down
Loading