Skip to content

Commit

Permalink
Internal renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
OlivierHecart committed Oct 12, 2023
1 parent 819f53e commit 851d2f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions zenoh/src/publication.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,11 +1053,11 @@ where
let (callback, receiver) = self.handler.into_cb_receiver_pair();
self.publisher
.session
.declare_matches_subscriber_inner(&self.publisher, callback)
.map(|sub_state| MatchingListener {
subscriber: MatchingListenerInner {
.declare_matches_listener_inner(&self.publisher, callback)
.map(|listener_state| MatchingListener {
listener: MatchingListenerInner {
publisher: self.publisher,
state: sub_state,
state: listener_state,
alive: true,
},
receiver,
Expand Down Expand Up @@ -1132,7 +1132,7 @@ impl<'a> Undeclarable<(), MatchingListenerUndeclaration<'a>> for MatchingListene
/// ```
#[zenoh_macros::unstable]
pub struct MatchingListener<'a, Receiver> {
pub(crate) subscriber: MatchingListenerInner<'a>,
pub(crate) listener: MatchingListenerInner<'a>,
pub receiver: Receiver,
}

Expand All @@ -1156,14 +1156,14 @@ impl<'a, Receiver> MatchingListener<'a, Receiver> {
/// ```
#[inline]
pub fn undeclare(self) -> MatchingListenerUndeclaration<'a> {
self.subscriber.undeclare()
self.listener.undeclare()
}
}

#[zenoh_macros::unstable]
impl<'a, T> Undeclarable<(), MatchingListenerUndeclaration<'a>> for MatchingListener<'a, T> {
fn undeclare_inner(self, _: ()) -> MatchingListenerUndeclaration<'a> {
Undeclarable::undeclare_inner(self.subscriber, ())
Undeclarable::undeclare_inner(self.listener, ())
}
}

Expand Down
16 changes: 8 additions & 8 deletions zenoh/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1446,38 +1446,38 @@ impl Session {
}

#[zenoh_macros::unstable]
pub(crate) fn declare_matches_subscriber_inner(
pub(crate) fn declare_matches_listener_inner(
&self,
publisher: &Publisher,
callback: Callback<'static, MatchingStatus>,
) -> ZResult<Arc<MatchingListenerState>> {
let mut state = zwrite!(self.state);
log::trace!("matches_subscriber({:?})", publisher.key_expr);
log::trace!("matches_listener({:?})", publisher.key_expr);

let id = state.decl_id_counter.fetch_add(1, Ordering::SeqCst);
let sub_state = Arc::new(MatchingListenerState {
let listener_state = Arc::new(MatchingListenerState {
id,
current: std::sync::Mutex::new(false),
destination: publisher.destination,
key_expr: publisher.key_expr.clone().into_owned(),
callback,
});
state.matching_listeners.insert(id, sub_state.clone());
state.matching_listeners.insert(id, listener_state.clone());
drop(state);
match sub_state.current.lock() {
match listener_state.current.lock() {
Ok(mut current) => {
if self
.matching_status(&publisher.key_expr, sub_state.destination)
.matching_status(&publisher.key_expr, listener_state.destination)
.map(|s| s.is_matching())
.unwrap_or(true)
{
*current = true;
(sub_state.callback)(MatchingStatus { matching: true });
(listener_state.callback)(MatchingStatus { matching: true });
}
}
Err(e) => log::error!("Error trying to acquire MathginListener lock: {}", e),
}
Ok(sub_state)
Ok(listener_state)
}

#[zenoh_macros::unstable]
Expand Down

0 comments on commit 851d2f4

Please sign in to comment.