Skip to content

Commit

Permalink
Clear parameter cache on set or delete
Browse files Browse the repository at this point in the history
  • Loading branch information
adnanademovic committed Aug 7, 2023
1 parent 00fe624 commit 0624d06
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions rosrust/src/api/ros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -529,15 +529,21 @@ impl Parameter {
}

pub fn set<T: Serialize>(&self, value: &T) -> Response<()> {
self.master.set_param::<T>(&self.name, value).and(Ok(()))
self.master.set_param::<T>(&self.name, value)?;
self.clear_param_cache();
Ok(())
}

pub fn set_raw(&self, value: xml_rpc::Value) -> Response<()> {
self.master.set_param_any(&self.name, value).and(Ok(()))
self.master.set_param_any(&self.name, value)?;
self.clear_param_cache();
Ok(())
}

pub fn delete(&self) -> Response<()> {
self.master.delete_param(&self.name).and(Ok(()))
self.master.delete_param(&self.name)?;
self.clear_param_cache();
Ok(())
}

pub fn exists(&self) -> Response<bool> {
Expand All @@ -547,6 +553,10 @@ impl Parameter {
pub fn search(&self) -> Response<String> {
self.master.search_param(&self.name)
}

fn clear_param_cache(&self) {
self.param_cache.lock().expect(FAILED_TO_LOCK).data.clear();
}
}

fn yaml_to_xmlrpc(val: Yaml) -> Result<xml_rpc::Value> {
Expand Down

0 comments on commit 0624d06

Please sign in to comment.