Skip to content

Commit

Permalink
refactor(hydro_deploy)!: make Service::collect_resources take `&sel…
Browse files Browse the repository at this point in the history
…f` instead of `&mut self` (#1348)

#430 but still has `RwLock` wrapping

Depends on #1347
  • Loading branch information
MingweiSamuel authored Jul 22, 2024
1 parent c5a8de2 commit 2286558
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion hydro_deploy/core/src/custom_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl CustomService {

#[async_trait]
impl Service for CustomService {
fn collect_resources(&mut self, _resource_batch: &mut ResourceBatch) {
fn collect_resources(&self, _resource_batch: &mut ResourceBatch) {
if self.launched_host.is_some() {
return;
}
Expand Down
6 changes: 3 additions & 3 deletions hydro_deploy/core/src/deployment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,16 @@ impl Deployment {
.collect::<Vec<_>>();
self.services = active_services;

for service in self.services.iter_mut() {
for service in self.services.iter() {
service
.upgrade()
.unwrap()
.write()
.read()
.await
.collect_resources(&mut resource_batch);
}

for host in self.hosts.iter_mut() {
for host in self.hosts.iter() {
host.collect_resources(&mut resource_batch);
}

Expand Down
2 changes: 1 addition & 1 deletion hydro_deploy/core/src/hydroflow_crate/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl HydroflowCrateService {

#[async_trait]
impl Service for HydroflowCrateService {
fn collect_resources(&mut self, _resource_batch: &mut ResourceBatch) {
fn collect_resources(&self, _resource_batch: &mut ResourceBatch) {
if self.launched_host.is_some() {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion hydro_deploy/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ pub trait Service: Send + Sync {
///
/// This should also perform any "free", non-blocking computations (compilations),
/// because the `deploy` method will be called after these resources are allocated.
fn collect_resources(&mut self, resource_batch: &mut ResourceBatch);
fn collect_resources(&self, resource_batch: &mut ResourceBatch);

/// Connects to the acquired resources and prepares the service to be launched.
async fn deploy(&mut self, resource_result: &Arc<ResourceResult>) -> Result<()>;
Expand Down

0 comments on commit 2286558

Please sign in to comment.