Skip to content

Commit 40cc200

Browse files
authored
remove some &mut self for Downstairs (oxidecomputer#766)
1 parent 7a51450 commit 40cc200

File tree

1 file changed

+19
-19
lines changed

1 file changed

+19
-19
lines changed

downstairs/src/lib.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ where
554554
writes: writes.to_vec(),
555555
};
556556

557-
let mut d = ad.lock().await;
557+
let d = ad.lock().await;
558558
d.add_work(upstairs_connection, *job_id, new_write).await?;
559559
Some(*job_id)
560560
}
@@ -588,7 +588,7 @@ where
588588
extent_limit: *extent_limit,
589589
};
590590

591-
let mut d = ad.lock().await;
591+
let d = ad.lock().await;
592592
d.add_work(upstairs_connection, *job_id, new_flush).await?;
593593
Some(*job_id)
594594
}
@@ -616,7 +616,7 @@ where
616616
writes: writes.to_vec(),
617617
};
618618

619-
let mut d = ad.lock().await;
619+
let d = ad.lock().await;
620620
d.add_work(upstairs_connection, *job_id, new_write).await?;
621621
Some(*job_id)
622622
}
@@ -644,7 +644,7 @@ where
644644
requests: requests.to_vec(),
645645
};
646646

647-
let mut d = ad.lock().await;
647+
let d = ad.lock().await;
648648
d.add_work(upstairs_connection, *job_id, new_read).await?;
649649
Some(*job_id)
650650
}
@@ -673,7 +673,7 @@ where
673673
extent: *extent_id,
674674
};
675675

676-
let mut d = ad.lock().await;
676+
let d = ad.lock().await;
677677
d.add_work(upstairs_connection, *job_id, ext_close).await?;
678678
Some(*job_id)
679679
}
@@ -708,7 +708,7 @@ where
708708
repair_downstairs: vec![], // Unused in the downstairs
709709
};
710710

711-
let mut d = ad.lock().await;
711+
let d = ad.lock().await;
712712
d.add_work(upstairs_connection, *job_id, new_flush).await?;
713713
Some(*job_id)
714714
}
@@ -742,7 +742,7 @@ where
742742
repair_downstairs: vec![],
743743
};
744744

745-
let mut d = ad.lock().await;
745+
let d = ad.lock().await;
746746
debug!(d.log, "Received ExtentLiveRepair {}", job_id);
747747
d.add_work(upstairs_connection, *job_id, new_repair).await?;
748748
Some(*job_id)
@@ -771,7 +771,7 @@ where
771771
extent: *extent_id,
772772
};
773773

774-
let mut d = ad.lock().await;
774+
let d = ad.lock().await;
775775
d.add_work(upstairs_connection, *job_id, new_open).await?;
776776
Some(*job_id)
777777
}
@@ -796,7 +796,7 @@ where
796796
dependencies: dependencies.to_vec(),
797797
};
798798

799-
let mut d = ad.lock().await;
799+
let d = ad.lock().await;
800800
debug!(d.log, "Received NoOP {}", job_id);
801801
d.add_work(upstairs_connection, *job_id, new_open).await?;
802802
Some(*job_id)
@@ -1464,7 +1464,7 @@ where
14641464
negotiated = 4;
14651465

14661466
{
1467-
let mut ds = ads.lock().await;
1467+
let ds = ads.lock().await;
14681468
let mut work = ds.work_lock(
14691469
upstairs_connection.unwrap(),
14701470
).await?;
@@ -1831,7 +1831,7 @@ impl Downstairs {
18311831
* newly active Upstairs.
18321832
*/
18331833
async fn work_lock(
1834-
&mut self,
1834+
&self,
18351835
upstairs_connection: UpstairsConnection,
18361836
) -> Result<MutexGuard<'_, Work>> {
18371837
let upstairs_uuid = upstairs_connection.upstairs_id;
@@ -1863,15 +1863,15 @@ impl Downstairs {
18631863
}
18641864

18651865
async fn jobs(
1866-
&mut self,
1866+
&self,
18671867
upstairs_connection: UpstairsConnection,
18681868
) -> Result<usize> {
18691869
let work = self.work_lock(upstairs_connection).await?;
18701870
Ok(work.jobs())
18711871
}
18721872

18731873
async fn new_work(
1874-
&mut self,
1874+
&self,
18751875
upstairs_connection: UpstairsConnection,
18761876
) -> Result<Vec<u64>> {
18771877
let work = self.work_lock(upstairs_connection).await?;
@@ -1880,7 +1880,7 @@ impl Downstairs {
18801880

18811881
// Add work to the Downstairs
18821882
async fn add_work(
1883-
&mut self,
1883+
&self,
18841884
upstairs_connection: UpstairsConnection,
18851885
ds_id: u64,
18861886
work: IOop,
@@ -1920,7 +1920,7 @@ impl Downstairs {
19201920

19211921
#[cfg(test)]
19221922
async fn get_job(
1923-
&mut self,
1923+
&self,
19241924
upstairs_connection: UpstairsConnection,
19251925
ds_id: u64,
19261926
) -> Result<DownstairsWork> {
@@ -1930,7 +1930,7 @@ impl Downstairs {
19301930

19311931
// Downstairs, move a job to in_progress, if we can
19321932
async fn in_progress(
1933-
&mut self,
1933+
&self,
19341934
upstairs_connection: UpstairsConnection,
19351935
ds_id: u64,
19361936
) -> Result<Option<u64>> {
@@ -2287,7 +2287,7 @@ impl Downstairs {
22872287
* - putting the id on the completed list.
22882288
*/
22892289
async fn complete_work(
2290-
&mut self,
2290+
&self,
22912291
upstairs_connection: UpstairsConnection,
22922292
ds_id: u64,
22932293
m: Message,
@@ -2619,7 +2619,7 @@ impl Downstairs {
26192619
}
26202620
}
26212621

2622-
fn is_active(&mut self, connection: UpstairsConnection) -> bool {
2622+
fn is_active(&self, connection: UpstairsConnection) -> bool {
26232623
let uuid = connection.upstairs_id;
26242624
if let Some(active_upstairs) = self.active_upstairs.get(&uuid) {
26252625
active_upstairs.upstairs_connection == connection
@@ -2628,7 +2628,7 @@ impl Downstairs {
26282628
}
26292629
}
26302630

2631-
fn active_upstairs(&mut self) -> Vec<UpstairsConnection> {
2631+
fn active_upstairs(&self) -> Vec<UpstairsConnection> {
26322632
self.active_upstairs
26332633
.values()
26342634
.map(|x| x.upstairs_connection)

0 commit comments

Comments
 (0)