@@ -622,6 +622,7 @@ impl<S: Symbol> Mutant<S> {
622
622
623
623
// synchronize swapping and deference with other threads
624
624
let _guard = (*old_ptr)._defer_drop.lock();
625
+ let _other_guard = (*new_ptr)._defer_drop.lock();
625
626
626
627
// replace the old reference with the new one inside the haplotype ref
627
628
// this swaps the reference count of the old reference for the new one
@@ -1039,7 +1040,6 @@ mod tests {
1039
1040
let wt = Wildtype::new(symbols, &attribute_definition);
1040
1041
1041
1042
generation_provider.increment();
1042
- dbg!(&generation_provider);
1043
1043
let ht = wt.create_descendant(vec![0], vec![Nt::G]);
1044
1044
let ht_id = ht.get_block_id();
1045
1045
assert_eq!(wt.get_tree(), format!("('{}':1)wt;", ht_id));
@@ -1109,11 +1109,11 @@ mod tests {
1109
1109
) {
1110
1110
use rand::prelude::*;
1111
1111
1112
- let mut rng = rand::thread_rng ();
1112
+ let mut rng = rand::rng ();
1113
1113
1114
1114
for i in 0..n_mutations {
1115
- let from = rng.gen_range (0..pop_size);
1116
- let to = rng.gen_range (0..pop_size);
1115
+ let from = rng.random_range (0..pop_size);
1116
+ let to = rng.random_range (0..pop_size);
1117
1117
1118
1118
let descendant = {
1119
1119
let ht = pop[from].lock().expect("Failed to lock ancestor.");
@@ -1134,8 +1134,8 @@ mod tests {
1134
1134
fn reader(pop: &[Mutex<HaplotypeRef<Nt>>], pop_size: usize, n_reads: usize, n_sites: usize) {
1135
1135
use rand::prelude::*;
1136
1136
for _ in 0..n_reads {
1137
- let mut rng = rand::thread_rng ();
1138
- let index = rng.gen_range (0..pop_size);
1137
+ let mut rng = rand::rng ();
1138
+ let index = rng.random_range (0..pop_size);
1139
1139
let ht = pop[index].lock().expect("Failed to lock haplotype.");
1140
1140
let sequence = ht.get_sequence();
1141
1141
assert_eq!(sequence.len(), n_sites);
@@ -1148,8 +1148,6 @@ mod tests {
1148
1148
use std::sync::Mutex;
1149
1149
use std::thread;
1150
1150
1151
- // TODO: investigate potential smallvec issue (unreachable code entered?)
1152
-
1153
1151
let n_sites = 7;
1154
1152
let n_symbols = 4;
1155
1153
@@ -1169,8 +1167,10 @@ mod tests {
1169
1167
s.spawn(|| reader(&pop, pop_size, n_reads, n_sites));
1170
1168
});
1171
1169
1172
- let n_leaked = N_LEAKED.load(Ordering::Relaxed);
1173
- let n_dropped = N_DROPPED.load(Ordering::Relaxed);
1170
+ thread::sleep(std::time::Duration::from_millis(100));
1171
+
1172
+ let n_leaked = N_LEAKED.load(Ordering::Acquire);
1173
+ let n_dropped = N_DROPPED.load(Ordering::Acquire);
1174
1174
assert_eq!(
1175
1175
n_leaked, n_dropped,
1176
1176
"Number of leaked and dropped nodes should be equal."
0 commit comments