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
8 changes: 5 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ jobs:
- name: Run cargo check (without dev-dependencies to catch missing feature flags)
if: startsWith(matrix.rust, 'nightly')
run: cargo check -Z features=dev_dep
- run: cargo test --features __test --all
- run: cargo build --no-default-features --all
- run: cargo test --all
- run: cargo test --no-default-features --tests
- run: cargo build -p event-listener-strategy --no-default-features
- name: Install cargo-hack
uses: taiki-e/install-action@cargo-hack
- run: rustup target add thumbv7m-none-eabi
Expand All @@ -56,6 +57,7 @@ jobs:
- name: Install Rust
run: rustup update ${{ matrix.rust }} && rustup default ${{ matrix.rust }}
- run: cargo build --all
- run: cargo build --all --no-default-features

clippy:
runs-on: ubuntu-latest
Expand All @@ -79,7 +81,7 @@ jobs:
- uses: actions/checkout@v3
- name: Install Rust
run: rustup toolchain install nightly --component miri && rustup default nightly
- run: cargo miri test --features __test --all
- run: cargo miri test --all
env:
MIRIFLAGS: -Zmiri-strict-provenance -Zmiri-symbolic-alignment-check -Zmiri-disable-isolation
RUSTFLAGS: ${{ env.RUSTFLAGS }} -Z randomize-layout
Expand Down
6 changes: 1 addition & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ exclude = ["/.*"]
default = ["std"]
std = ["parking"]

# Unstable, test only feature. Do not enable this.
__test = []

[dependencies]
crossbeam-utils = { version = "0.8.12", default-features = false }
parking = { version = "2.0.0", optional = true }
slab = { version = "0.4.7", default-features = false }

[dev-dependencies]
futures-lite = "1.12.0"
waker-fn = "1"

[dev-dependencies.criterion]
Expand Down
23 changes: 16 additions & 7 deletions benches/bench.rs
Original file line number Diff line number Diff line change
@@ -1,22 +1,31 @@
use std::iter;
use std::pin::Pin;

use criterion::{criterion_group, criterion_main, Criterion};
use event_listener::Event;
use event_listener::{Event, EventListener};

const COUNT: usize = 8000;

fn bench_events(c: &mut Criterion) {
c.bench_function("notify_and_wait", |b| {
let ev = Event::new();
b.iter(|| {
let mut handles = Vec::with_capacity(COUNT);
let mut handles = iter::repeat_with(|| EventListener::new(&ev))
.take(COUNT)
.collect::<Vec<_>>();

for _ in 0..COUNT {
handles.push(ev.listen());
b.iter(|| {
for handle in &mut handles {
// SAFETY: The handle is not moved out.
let listener = unsafe { Pin::new_unchecked(handle) };
listener.listen();
}

ev.notify(COUNT);

for handle in handles {
handle.wait();
for handle in &mut handles {
// SAFETY: The handle is not moved out.
let listener = unsafe { Pin::new_unchecked(handle) };
listener.wait();
}
});
});
Expand Down
8 changes: 4 additions & 4 deletions examples/mutex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@ impl<T> Mutex<T> {
// Start listening and then try locking again.
listener = Some(self.lock_ops.listen());
}
Some(l) => {
Some(mut l) => {
// Wait until a notification is received.
l.wait();
l.as_mut().wait();
}
}
}
Expand All @@ -88,9 +88,9 @@ impl<T> Mutex<T> {
// Start listening and then try locking again.
listener = Some(self.lock_ops.listen());
}
Some(l) => {
Some(mut l) => {
// Wait until a notification is received.
if !l.wait_deadline(deadline) {
if !l.as_mut().wait_deadline(deadline) {
return None;
}
}
Expand Down
213 changes: 0 additions & 213 deletions src/inner.rs

This file was deleted.

Loading