Skip to content

Commit b6d5de8

Browse files
authored
Merge pull request async-rs#60 from smol-rs/slab
Replace vec-arena with slab
2 parents 8be73f1 + 78a0de9 commit b6d5de8

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ log = "0.4.11"
2222
once_cell = "1.4.1"
2323
parking = "2.0.0"
2424
polling = "2.0.0"
25+
slab = "0.4.2"
2526
socket2 = { version = "0.4.0", features = ["all"] }
26-
vec-arena = "1.0.0"
2727
waker-fn = "1.1.0"
2828

2929
[target."cfg(unix)".dependencies]

src/reactor.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use concurrent_queue::ConcurrentQueue;
1515
use futures_lite::future;
1616
use once_cell::sync::Lazy;
1717
use polling::{Event, Poller};
18-
use vec_arena::Arena;
18+
use slab::Slab;
1919

2020
const READ: usize = 0;
2121
const WRITE: usize = 1;
@@ -38,7 +38,7 @@ pub(crate) struct Reactor {
3838
ticker: AtomicUsize,
3939

4040
/// Registered sources.
41-
sources: Mutex<Arena<Arc<Source>>>,
41+
sources: Mutex<Slab<Arc<Source>>>,
4242

4343
/// Temporary storage for I/O events when polling the reactor.
4444
///
@@ -67,7 +67,7 @@ impl Reactor {
6767
Reactor {
6868
poller: Poller::new().expect("cannot initialize I/O event notification"),
6969
ticker: AtomicUsize::new(0),
70-
sources: Mutex::new(Arena::new()),
70+
sources: Mutex::new(Slab::new()),
7171
events: Mutex::new(Vec::new()),
7272
timers: Mutex::new(BTreeMap::new()),
7373
timer_ops: ConcurrentQueue::bounded(1000),
@@ -90,7 +90,7 @@ impl Reactor {
9090
// Create an I/O source for this file descriptor.
9191
let source = {
9292
let mut sources = self.sources.lock().unwrap();
93-
let key = sources.next_vacant();
93+
let key = sources.vacant_entry().key();
9494
let source = Arc::new(Source {
9595
raw,
9696
key,
@@ -362,7 +362,7 @@ struct Direction {
362362
/// Wakers of tasks waiting for the next event.
363363
///
364364
/// Registered by `Async::readable()` and `Async::writable()`.
365-
wakers: Arena<Option<Waker>>,
365+
wakers: Slab<Option<Waker>>,
366366
}
367367

368368
impl Direction {

0 commit comments

Comments
 (0)