Skip to content

Commit 9fcf0ff

Browse files
authored
Merge pull request #9 from cuviper/rustc-crossbeam
Update crossbeam and release 0.3.2
2 parents c8ec88d + d79ec98 commit 9fcf0ff

File tree

4 files changed

+29
-20
lines changed

4 files changed

+29
-20
lines changed

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[package]
22
name = "rustc-rayon"
33
# Reminder to update html_rool_url in lib.rs when updating version
4-
version = "0.3.1"
4+
version = "0.3.2"
55
authors = ["Niko Matsakis <[email protected]>",
66
"Josh Stone <[email protected]>"]
77
description = "Simple work-stealing parallelism for Rust - fork for rustc"
@@ -20,7 +20,7 @@ exclude = ["ci"]
2020

2121
[dependencies]
2222
rayon-core = { version = "0.3", path = "rayon-core", package = "rustc-rayon-core" }
23-
crossbeam-deque = "0.7.2"
23+
crossbeam-deque = "0.8.0"
2424

2525
# This is a public dependency!
2626
[dependencies.either]

rayon-core/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "rustc-rayon-core"
3-
version = "0.3.1" # reminder to update html_root_url attribute
3+
version = "0.3.2" # reminder to update html_root_url attribute
44
authors = ["Niko Matsakis <[email protected]>",
55
"Josh Stone <[email protected]>"]
66
description = "Core APIs for Rayon - fork for rustc"
@@ -17,9 +17,8 @@ categories = ["concurrency"]
1717
[dependencies]
1818
num_cpus = "1.2"
1919
lazy_static = "1"
20-
crossbeam-deque = "0.7.2"
21-
crossbeam-queue = "0.2"
22-
crossbeam-utils = "0.7"
20+
crossbeam-deque = "0.8.0"
21+
crossbeam-utils = "0.8.0"
2322

2423
[dev-dependencies]
2524
rand = "0.7"

rayon-core/src/job.rs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::latch::Latch;
22
use crate::tlv;
33
use crate::unwind;
4-
use crossbeam_queue::SegQueue;
4+
use crossbeam_deque::{Injector, Steal};
55
use std::any::Any;
66
use std::cell::UnsafeCell;
77
use std::mem;
@@ -191,13 +191,13 @@ impl<T> JobResult<T> {
191191

192192
/// Indirect queue to provide FIFO job priority.
193193
pub(super) struct JobFifo {
194-
inner: SegQueue<JobRef>,
194+
inner: Injector<JobRef>,
195195
}
196196

197197
impl JobFifo {
198198
pub(super) fn new() -> Self {
199199
JobFifo {
200-
inner: SegQueue::new(),
200+
inner: Injector::new(),
201201
}
202202
}
203203

@@ -213,6 +213,12 @@ impl JobFifo {
213213
impl Job for JobFifo {
214214
unsafe fn execute(this: *const Self) {
215215
// We "execute" a queue by executing its first job, FIFO.
216-
(*this).inner.pop().expect("job in fifo queue").execute()
216+
loop {
217+
match (*this).inner.steal() {
218+
Steal::Success(job_ref) => break job_ref.execute(),
219+
Steal::Empty => panic!("FIFO is empty"),
220+
Steal::Retry => {}
221+
}
222+
}
217223
}
218224
}

rayon-core/src/registry.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ use crate::{
88
AcquireThreadHandler, DeadlockHandler, ErrorKind, ExitHandler, PanicHandler,
99
ReleaseThreadHandler, StartHandler, ThreadPoolBuildError, ThreadPoolBuilder,
1010
};
11-
use crossbeam_deque::{Steal, Stealer, Worker};
12-
use crossbeam_queue::SegQueue;
11+
use crossbeam_deque::{Injector, Steal, Stealer, Worker};
1312
use std::any::Any;
1413
use std::cell::Cell;
1514
use std::collections::hash_map::DefaultHasher;
@@ -135,7 +134,7 @@ where
135134
pub struct Registry {
136135
thread_infos: Vec<ThreadInfo>,
137136
sleep: Sleep,
138-
injected_jobs: SegQueue<JobRef>,
137+
injected_jobs: Injector<JobRef>,
139138
panic_handler: Option<Box<PanicHandler>>,
140139
pub(crate) deadlock_handler: Option<Box<DeadlockHandler>>,
141140
start_handler: Option<Box<StartHandler>>,
@@ -240,7 +239,7 @@ impl Registry {
240239
let registry = Arc::new(Registry {
241240
thread_infos: stealers.into_iter().map(ThreadInfo::new).collect(),
242241
sleep: Sleep::new(n_threads),
243-
injected_jobs: SegQueue::new(),
242+
injected_jobs: Injector::new(),
244243
terminate_latch: CountLatch::new(),
245244
panic_handler: builder.take_panic_handler(),
246245
deadlock_handler: builder.take_deadlock_handler(),
@@ -415,13 +414,18 @@ impl Registry {
415414
}
416415

417416
fn pop_injected_job(&self, worker_index: usize) -> Option<JobRef> {
418-
let job = self.injected_jobs.pop().ok();
419-
if job.is_some() {
420-
log!(UninjectedWork {
421-
worker: worker_index
422-
});
417+
loop {
418+
match self.injected_jobs.steal() {
419+
Steal::Success(job) => {
420+
log!(UninjectedWork {
421+
worker: worker_index
422+
});
423+
return Some(job);
424+
}
425+
Steal::Empty => return None,
426+
Steal::Retry => {}
427+
}
423428
}
424-
job
425429
}
426430

427431
/// If already in a worker-thread of this registry, just execute `op`.

0 commit comments

Comments
 (0)