Skip to content

chore: rework mutagen controller, add polling - #65

Merged
deansheather merged 5 commits into
dean/sync-wiringfrom
dean/mutagen-controller-rework
Apr 2, 2025
Merged

deansheather merged 5 commits into
dean/sync-wiringfrom
dean/mutagen-controller-rework

Conversation

@deansheather

Copy link
Copy Markdown
Collaborator
  • Use locks during operations for daemon process consistency
  • Use a state model for UI rendering
  • Use events to signal state changes
  • Fix some tooltip problems that arise from polling

- Use locks during operations for daemon process consistency
- Use a state model for UI rendering
- Use events to signal state changes
- Fix some tooltip problems that arise from polling
@deansheather
deansheather requested a review from spikecurtis April 1, 2025 01:46
Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Outdated
_state = state;
// Since the event handlers could block (or call back the
// CredentialManager and deadlock), we run these in a new task.
if (StateChanged == null) return;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't we need to check if the state has actually changed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided not to implement equality for the state type because I would also need to implement equality for the sync session model (and all of it's sub types) which seems like a lot. I don't think there's any side effects of calling this every time it changes though

Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Outdated
// Since the event handlers could block (or call back the
// CredentialManager and deadlock), we run these in a new task.
if (StateChanged == null) return;
Task.Run(() => { StateChanged?.Invoke(this, state); });

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are Events threadsafe? If we start this in another task, could it be modified under us in a way that breaks stuff?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll copy the EventHandler to a variable before calling it, which I believe makes it thread safe

Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Resolved
Comment thread App/Services/MutagenController.cs Resolved
@deansheather
deansheather requested a review from spikecurtis April 2, 2025 02:20

@spikecurtis spikecurtis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@deansheather
deansheather requested a review from spikecurtis April 2, 2025 05:58
@deansheather
deansheather merged commit 1193e4b into dean/sync-wiring Apr 2, 2025
@deansheather
deansheather deleted the dean/mutagen-controller-rework branch April 2, 2025 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants