Skip to content

Commit

Permalink
refactor: improve code
Browse files Browse the repository at this point in the history
  • Loading branch information
wyfo committed Jan 22, 2025
1 parent 8890e54 commit c12b2dc
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/pubsub.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub(crate) fn disable_all_data_routes(tables: &mut Tables) {
pub(crate) fn disable_all_data_routes_rec(res: &mut Arc<Resource>) {
let res = get_mut_unchecked(res);
if let Some(ctx) = &mut res.context {
ctx.data_routes.write().unwrap().clear();
ctx.disable_data_routes();
}
for child in res.children.values_mut() {
disable_all_data_routes_rec(child);
Expand Down
2 changes: 1 addition & 1 deletion zenoh/src/net/routing/dispatcher/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ pub(crate) fn disable_all_query_routes(tables: &mut Tables) {
pub(crate) fn disable_all_query_routes_rec(res: &mut Arc<Resource>) {
let res = get_mut_unchecked(res);
if let Some(ctx) = &mut res.context {
ctx.data_routes.write().unwrap().clear();
ctx.disable_query_routes();
}
for child in res.children.values_mut() {
disable_all_query_routes_rec(child);
Expand Down
4 changes: 2 additions & 2 deletions zenoh/src/net/routing/dispatcher/resource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,11 @@ impl ResourceContext {
}

pub(crate) fn disable_data_routes(&mut self) {
self.data_routes.write().unwrap().clear();
self.data_routes.get_mut().unwrap().clear();
}

pub(crate) fn disable_query_routes(&mut self) {
self.query_routes.write().unwrap().clear();
self.query_routes.get_mut().unwrap().clear();
}
}

Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/net/routing/hat/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,15 +210,15 @@ impl HatBaseTrait for HatCode {
}

for mut res in subs_matches {
if let Some(ctx) = &res.context {
ctx.data_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_data_routes();
Resource::clean(&mut res);
}
for mut res in qabls_matches {
if let Some(ctx) = &res.context {
ctx.query_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_query_routes();
Resource::clean(&mut res);
}
wtables.faces.remove(&face.id);
Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/net/routing/hat/linkstate_peer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -347,15 +347,15 @@ impl HatBaseTrait for HatCode {
}

for mut res in subs_matches {
if let Some(ctx) = &res.context {
ctx.data_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_data_routes();
Resource::clean(&mut res);
}
for mut res in qabls_matches {
if let Some(ctx) = &res.context {
ctx.query_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_query_routes();
Resource::clean(&mut res);
}
wtables.faces.remove(&face.id);
Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/net/routing/hat/p2p_peer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,15 +298,15 @@ impl HatBaseTrait for HatCode {
}

for mut res in subs_matches {
if let Some(ctx) = &res.context {
ctx.data_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_data_routes();
Resource::clean(&mut res);
}
for mut res in qabls_matches {
if let Some(ctx) = &res.context {
ctx.query_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_query_routes();
Resource::clean(&mut res);
}
wtables.faces.remove(&face.id);
Expand Down
12 changes: 6 additions & 6 deletions zenoh/src/net/routing/hat/router/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -517,15 +517,15 @@ impl HatBaseTrait for HatCode {
}

for mut res in subs_matches {
if let Some(ctx) = &res.context {
ctx.data_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_data_routes();
Resource::clean(&mut res);
}
for mut res in qabls_matches {
if let Some(ctx) = &res.context {
ctx.query_routes.write().unwrap().clear();
}
get_mut_unchecked(&mut res)
.context_mut()
.disable_query_routes();
Resource::clean(&mut res);
}
wtables.faces.remove(&face.id);
Expand Down

0 comments on commit c12b2dc

Please sign in to comment.