cacheline aligned heartbeat atomics
This commit is contained in:
parent
af8103b843
commit
4f9c5c00bb
|
@ -752,6 +752,7 @@ use std::{
|
||||||
time::Duration,
|
time::Duration,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crossbeam::utils::CachePadded;
|
||||||
use job::*;
|
use job::*;
|
||||||
use parking_lot::{Condvar, Mutex};
|
use parking_lot::{Condvar, Mutex};
|
||||||
use util::DropGuard;
|
use util::DropGuard;
|
||||||
|
@ -760,7 +761,7 @@ pub struct Scope {
|
||||||
join_count: Cell<usize>,
|
join_count: Cell<usize>,
|
||||||
context: Arc<Context>,
|
context: Arc<Context>,
|
||||||
index: usize,
|
index: usize,
|
||||||
heartbeat: Arc<AtomicBool>,
|
heartbeat: Arc<CachePadded<AtomicBool>>,
|
||||||
queue: UnsafeCell<JobList>,
|
queue: UnsafeCell<JobList>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1058,7 +1059,7 @@ struct Context {
|
||||||
|
|
||||||
struct SharedContext {
|
struct SharedContext {
|
||||||
jobs: BTreeMap<usize, NonNull<Job>>,
|
jobs: BTreeMap<usize, NonNull<Job>>,
|
||||||
heartbeats: BTreeMap<usize, Weak<AtomicBool>>,
|
heartbeats: BTreeMap<usize, Weak<CachePadded<AtomicBool>>>,
|
||||||
// monotonic increasing id
|
// monotonic increasing id
|
||||||
heartbeats_id: usize,
|
heartbeats_id: usize,
|
||||||
should_stop: bool,
|
should_stop: bool,
|
||||||
|
@ -1067,11 +1068,11 @@ struct SharedContext {
|
||||||
unsafe impl Send for SharedContext {}
|
unsafe impl Send for SharedContext {}
|
||||||
|
|
||||||
impl SharedContext {
|
impl SharedContext {
|
||||||
fn new_heartbeat(&mut self) -> (Arc<AtomicBool>, usize) {
|
fn new_heartbeat(&mut self) -> (Arc<CachePadded<AtomicBool>>, usize) {
|
||||||
let index = self.heartbeats_id;
|
let index = self.heartbeats_id;
|
||||||
self.heartbeats_id.checked_add(1).unwrap();
|
self.heartbeats_id.checked_add(1).unwrap();
|
||||||
|
|
||||||
let is_set = Arc::new(AtomicBool::new(false));
|
let is_set = Arc::new(CachePadded::new(AtomicBool::new(false)));
|
||||||
let weak = Arc::downgrade(&is_set);
|
let weak = Arc::downgrade(&is_set);
|
||||||
|
|
||||||
self.heartbeats.insert(index, weak);
|
self.heartbeats.insert(index, weak);
|
||||||
|
|
Loading…
Reference in a new issue