Skip to content

Commit 9beaa04

Browse files
authored
chore: update dependancies (#79)
1 parent af07dcc commit 9beaa04

File tree

9 files changed

+17
-141
lines changed

9 files changed

+17
-141
lines changed

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@ license = "Apache-2.0/MIT"
77
keywords = ["pubsub", "lock-free", "queue","async","futures"]
88
repository = "https://github.com/filipdulic/bus-queue"
99
readme = "README.md"
10-
edition = "2018"
10+
edition = "2024"
1111

1212
[dependencies]
13-
arc-swap = {version = "0.4.6", optional = true}
14-
futures-core = "0.3.5"
15-
futures-sink = "0.3.5"
16-
event-listener = "1.0.0"
13+
arc-swap = {version = "1.7.1", optional = true}
14+
futures-core = "0.3.31"
15+
futures-sink = "0.3.31"
16+
event-listener = "5.4.1"
1717
# conc = {version="0.5.1", optional = true}
1818

1919
[dev-dependencies]
20-
rand = "0.7.3"
21-
futures-test = "0.3.5"
22-
futures = {version = "0.3.5", features = ["thread-pool"]}
20+
# rand = "0.10.0-rc.0"
21+
futures-test = "0.3.31"
22+
futures = {version = "0.3.31", features = ["thread-pool"]}
23+
serial_test = "3.2.0"
2324

2425
[features]
2526
default = ["arcswap", "rwlock"]

examples/async-simple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bus_queue::flavors::arc_swap::async_bounded;
22
use futures::executor::block_on;
3-
use futures::stream::{iter, StreamExt};
3+
use futures::stream::{StreamExt, iter};
44

55
fn main() {
66
let (publisher, subscriber1) = async_bounded(10);

src/async_publisher.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl<T, S: SwapSlot<T>> Sink<T> for AsyncPublisher<T, S> {
4040
self: Pin<&mut Self>,
4141
_: &mut task::Context<'_>,
4242
) -> Poll<Result<(), Self::Error>> {
43-
self.event.notify_all();
43+
self.event.notify(usize::MAX);
4444
Poll::Ready(Ok(()))
4545
}
4646

@@ -62,7 +62,7 @@ impl<T, S: SwapSlot<T>> PartialEq for AsyncPublisher<T, S> {
6262
impl<T, S: SwapSlot<T>> Drop for AsyncPublisher<T, S> {
6363
fn drop(&mut self) {
6464
self.publisher.close();
65-
self.event.notify_all();
65+
self.event.notify(usize::MAX);
6666
}
6767
}
6868

src/async_subscriber.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ use crate::swap_slot::SwapSlot;
44
use event_listener::{Event, EventListener};
55
//use piper::{Event, EventListener};
66
use futures_core::{
7+
Stream,
78
future::Future,
89
task::{self, Poll},
9-
Stream,
1010
};
1111
use std::pin::Pin;
1212
use std::sync::Arc;

src/flavors/arc_swap.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(dead_code)]
2-
use crate::{async_publisher, async_subscriber, publisher, subscriber, SwapSlot};
2+
use crate::{SwapSlot, async_publisher, async_subscriber, publisher, subscriber};
33
use arc_swap::ArcSwapOption;
44
use std::sync::Arc;
55

@@ -70,46 +70,3 @@ mod test {
7070
assert_eq!(Arc::strong_count(&arc.unwrap()), 2)
7171
}
7272
}
73-
74-
#[cfg(test)]
75-
mod allocation_tests {
76-
use crate::flavors::allocation_tests::{allocs_current_thread, reset_allocs_current_thread};
77-
78-
use super::*;
79-
80-
#[test]
81-
fn store_with_arc_does_not_allocate_new_arc() {
82-
let slot = Slot::<u32>::none();
83-
let arc = Arc::new(123u32);
84-
85-
// Ignore allocations from constructing `slot` and `arc`.
86-
reset_allocs_current_thread();
87-
88-
// This should only move / clone the Arc; no new heap allocation for T.
89-
slot.store(arc.clone());
90-
91-
// Might still be 0 or some tiny number depending on RwLock internals,
92-
// but definitely shouldn't be "one Arc allocation vs another" difference.
93-
let after = allocs_current_thread();
94-
assert_eq!(
95-
after, 0,
96-
"expected no additional allocations when storing an Arc"
97-
);
98-
}
99-
100-
#[test]
101-
fn store_with_value_allocates_arc() {
102-
let slot = Slot::<u32>::none();
103-
104-
reset_allocs_current_thread();
105-
106-
// This goes through `impl From<T> for Arc<T>` and must allocate.
107-
slot.store(5u32);
108-
109-
let after = allocs_current_thread();
110-
assert!(
111-
after == 1,
112-
"expected at least one allocation when storing a bare value T"
113-
);
114-
}
115-
}

src/flavors/mod.rs

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,3 @@ pub mod arc_swap;
33

44
#[cfg(feature = "rwlock")]
55
pub mod rw_lock;
6-
7-
#[cfg(test)]
8-
mod allocation_tests {
9-
use std::alloc::{GlobalAlloc, Layout, System};
10-
use std::cell::Cell;
11-
12-
struct CountingAlloc;
13-
14-
#[global_allocator]
15-
static GLOBAL: CountingAlloc = CountingAlloc;
16-
17-
thread_local! {
18-
// Each OS thread gets its own counter.
19-
static ALLOCS_THIS_THREAD: Cell<usize> = Cell::new(0);
20-
}
21-
22-
unsafe impl GlobalAlloc for CountingAlloc {
23-
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
24-
let ptr = System.alloc(layout);
25-
if !ptr.is_null() {
26-
// Only bump the counter for the *current* thread.
27-
ALLOCS_THIS_THREAD.with(|c| c.set(c.get() + 1));
28-
}
29-
ptr
30-
}
31-
32-
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
33-
System.dealloc(ptr, layout);
34-
}
35-
}
36-
37-
pub(crate) fn reset_allocs_current_thread() {
38-
ALLOCS_THIS_THREAD.with(|c| c.set(0));
39-
}
40-
41-
pub(crate) fn allocs_current_thread() -> usize {
42-
ALLOCS_THIS_THREAD.with(|c| c.get())
43-
}
44-
}

src/flavors/rw_lock.rs

Lines changed: 1 addition & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(dead_code)]
2-
use crate::{async_publisher, async_subscriber, publisher, subscriber, SwapSlot};
2+
use crate::{SwapSlot, async_publisher, async_subscriber, publisher, subscriber};
33
use std::sync::{Arc, RwLock};
44

55
pub struct Slot<T> {
@@ -69,46 +69,3 @@ mod test {
6969
assert_eq!(Arc::strong_count(&arc.unwrap()), 2)
7070
}
7171
}
72-
73-
#[cfg(test)]
74-
mod allocation_tests {
75-
use crate::flavors::allocation_tests::{allocs_current_thread, reset_allocs_current_thread};
76-
77-
use super::*;
78-
79-
#[test]
80-
fn store_with_arc_does_not_allocate_new_arc() {
81-
let slot = Slot::<u32>::none();
82-
let arc = Arc::new(123u32);
83-
84-
// Ignore allocations from constructing `slot` and `arc`.
85-
reset_allocs_current_thread();
86-
87-
// This should only move / clone the Arc; no new heap allocation for T.
88-
slot.store(arc.clone());
89-
90-
// Might still be 0 or some tiny number depending on RwLock internals,
91-
// but definitely shouldn't be "one Arc allocation vs another" difference.
92-
let after = allocs_current_thread();
93-
assert_eq!(
94-
after, 0,
95-
"expected no additional allocations when storing an Arc"
96-
);
97-
}
98-
99-
#[test]
100-
fn store_with_value_allocates_arc() {
101-
let slot = Slot::<u32>::none();
102-
103-
reset_allocs_current_thread();
104-
105-
// This goes through `impl From<T> for Arc<T>` and must allocate.
106-
slot.store(5u32);
107-
108-
let after = allocs_current_thread();
109-
assert!(
110-
after == 1,
111-
"expected at least one allocation when storing a bare value T"
112-
);
113-
}
114-
}

src/ring_buffer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use crate::atomic_counter::AtomicCounter;
2-
use std::sync::{atomic::AtomicBool, atomic::Ordering, Arc};
2+
use std::sync::{Arc, atomic::AtomicBool, atomic::Ordering};
33
// Use std mpsc's error types as our own
44
use crate::swap_slot::SwapSlot;
55
use std::fmt::Debug;

tests/async_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use bus_queue::flavors::arc_swap::async_bounded;
22
// use futures::{executor, pin_mut, task::Poll, task::SpawnExt, FutureExt, SinkExt, StreamExt};
3-
use futures::{pin_mut, task::Poll, FutureExt, SinkExt};
3+
use futures::{FutureExt, SinkExt, pin_mut, task::Poll};
44
use futures_test::task::noop_context;
55
use futures_test::{assert_stream_done, assert_stream_next, assert_stream_pending};
66
// use rand::Rng;

0 commit comments

Comments
 (0)