Adjust replace_with_new to fit with updates to Lox library
This commit is contained in:
parent
3e3f50c215
commit
6372e894ae
|
@ -90,6 +90,12 @@ impl LoxServerContext {
|
|||
return_bridges
|
||||
}
|
||||
|
||||
pub fn remove_single_bridge(&self) {
|
||||
let mut extra_bridges = self.extra_bridges.lock().unwrap();
|
||||
let length = extra_bridges.len();
|
||||
_ = extra_bridges.remove(length - 1)
|
||||
}
|
||||
|
||||
pub fn new_unreplaced_bridge(&self, bridge: BridgeLine) {
|
||||
let mut unreplaced_bridges = self.unreplaced_bridges.lock().unwrap();
|
||||
unreplaced_bridges.push(bridge);
|
||||
|
@ -115,11 +121,13 @@ impl LoxServerContext {
|
|||
|
||||
pub fn replace_with_new(&self, bridgeline: BridgeLine) -> bool {
|
||||
let mut ba_obj = self.ba.lock().unwrap();
|
||||
let mut db_obj = self.db.lock().unwrap();
|
||||
let mut eb_obj = self.extra_bridges.lock().unwrap();
|
||||
let mut available_bridge = eb_obj.last();
|
||||
|
||||
ba_obj.bridge_replace(&bridgeline, available_bridge, &mut db_obj)
|
||||
let eb_obj = self.extra_bridges.lock().unwrap();
|
||||
let available_bridge = eb_obj.last();
|
||||
// .last() doesn't actually remove the object so we still have to do that
|
||||
if eb_obj.len() > 0 {
|
||||
self.remove_single_bridge();
|
||||
}
|
||||
ba_obj.bridge_replace(&bridgeline, available_bridge)
|
||||
}
|
||||
|
||||
pub fn add_unreachable(&self, bridgeline: BridgeLine) -> bool {
|
||||
|
|
|
@ -142,17 +142,15 @@ async fn context_manager(mut context_rx: mpsc::Receiver<Command>) {
|
|||
println!("'Gone' BridgeLine NOT replaced, saved for next update! : {:?}", bridgeline);
|
||||
context.new_unreplaced_bridge(bridgeline);
|
||||
}
|
||||
} else if count < MAX_BRIDGES_PER_BUCKET {
|
||||
bucket[count] = bridgeline;
|
||||
count += 1;
|
||||
} else {
|
||||
if count < MAX_BRIDGES_PER_BUCKET {
|
||||
bucket[count] = bridgeline;
|
||||
count += 1;
|
||||
} else {
|
||||
// TODO: Decide the circumstances under which a bridge is allocated to an open_inv or spare bucket,
|
||||
// eventually also do some more fancy grouping of new resources, i.e., by type or region
|
||||
context.add_openinv_bucket(bucket);
|
||||
count = 0;
|
||||
bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
|
||||
}
|
||||
// TODO: Decide the circumstances under which a bridge is allocated to an open_inv or spare bucket,
|
||||
// eventually also do some more fancy grouping of new resources, i.e., by type or region
|
||||
context.add_openinv_bucket(bucket);
|
||||
count = 0;
|
||||
bucket = [BridgeLine::default(); MAX_BRIDGES_PER_BUCKET];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue