Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use &mut self in NotificationProcessor::init #3

Merged
merged 4 commits into from
Apr 25, 2024
Merged

Conversation

mkatychev
Copy link
Contributor

@mkatychev mkatychev commented Apr 24, 2024

This pr modifies the NotificationProcessor::init method to use &mut self. This allows us to consume resoruces in self and allows the JoinSet to be passed in later:

pub struct StatusReporter {
    input_rx: Option<UnboundedReceiver<StatusInput>>,
    reports: Arc<Mutex<HashMap<Uuid, Status>>>,
}

impl NotificationProcessor<OurMessage> for StatusReporter {
    fn init(&mut self, join_set: &mut JoinSet<()>) -> UnboundedSender<Notification<OurMessage>> {
        // we consume self.input_rx and set it to `None`
        let rx = self.input_rx.take().expect("uninitialized input_rx");
        spawn_some_other_rx(join_set, rx);

        self.spawn_notification_rx(join_set)
    }

    fn get_topics(&self) -> &[OurTopic] {
        &[OurTopic::Event]
    }
}

@mergify mergify bot added the feature label Apr 24, 2024
@jkleinknox
Copy link
Contributor

jkleinknox commented Apr 24, 2024

Since you are working in this area, would you be able to address the timeout cancellation issue? Essentially the timeout cancellation request doesn't reach the timeout manager in a reasonable amount of time causing the timeout manager to emit a timeout when the SM does not expect a timeout to be emitted.

// Currently the timeout
// is being cancelled, and the state is being changed to a state
// that does not expect a timeout to occur. Due to the coherency
// issue, the timeout is not cancelled, causing an unexpected scenario.

@mkatychev mkatychev marked this pull request as ready for review April 25, 2024 15:24
@mergify mergify bot merged commit e2c8a7b into main Apr 25, 2024
4 checks passed
Copy link

mergify bot commented Apr 25, 2024

[✅] @mkatychev: Use &mut self in NotificationProcessor::init has been merged successfully.

@mergify mergify bot removed the automerge label Apr 25, 2024
@mergify mergify bot deleted the feat/mut-init-np branch April 25, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants