Lock new node as soon as possible
This commit is contained in:
parent
6b4ed106f7
commit
1934478cfe
|
@ -241,6 +241,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
nodes[range].into_par_iter().for_each(|(_, pid)| {
|
nodes[range].into_par_iter().for_each(|(_, pid)| {
|
||||||
|
let node = zero.as_slice()[*pid].write();
|
||||||
let (mut search, mut insertion) = pool.pop();
|
let (mut search, mut insertion) = pool.pop();
|
||||||
let point = &points.as_slice()[*pid];
|
let point = &points.as_slice()[*pid];
|
||||||
search.reset();
|
search.reset();
|
||||||
|
@ -263,6 +264,7 @@ where
|
||||||
insertion.ef = ef_construction;
|
insertion.ef = ef_construction;
|
||||||
insert(
|
insert(
|
||||||
*pid,
|
*pid,
|
||||||
|
node,
|
||||||
&mut insertion,
|
&mut insertion,
|
||||||
&mut search,
|
&mut search,
|
||||||
&zero,
|
&zero,
|
||||||
|
@ -367,13 +369,13 @@ where
|
||||||
/// for the new node's neighbors if necessary before appending the new node to the layer.
|
/// for the new node's neighbors if necessary before appending the new node to the layer.
|
||||||
fn insert<P: Point>(
|
fn insert<P: Point>(
|
||||||
new: PointId,
|
new: PointId,
|
||||||
|
mut node: parking_lot::RwLockWriteGuard<ZeroNode>,
|
||||||
insertion: &mut Search,
|
insertion: &mut Search,
|
||||||
search: &mut Search,
|
search: &mut Search,
|
||||||
layer: &[RwLock<ZeroNode>],
|
layer: &[RwLock<ZeroNode>],
|
||||||
points: &[P],
|
points: &[P],
|
||||||
heuristic: &Option<Heuristic>,
|
heuristic: &Option<Heuristic>,
|
||||||
) {
|
) {
|
||||||
let mut node = layer[new].write();
|
|
||||||
let found = match heuristic {
|
let found = match heuristic {
|
||||||
None => search.select_simple(M * 2),
|
None => search.select_simple(M * 2),
|
||||||
Some(heuristic) => search.select_heuristic(&points[new], layer, points, *heuristic),
|
Some(heuristic) => search.select_heuristic(&points[new], layer, points, *heuristic),
|
||||||
|
|
Loading…
Reference in New Issue