Skip to content

Conversation

@jeanlrnt
Copy link
Owner

@jeanlrnt jeanlrnt commented Jan 2, 2026

No description provided.

Copilot AI and others added 4 commits January 2, 2026 11:47
…Registry.cs, MiniCronTests.EventInvocationOutsideLock.cs

Co-authored-by: jeanlrnt <[email protected]>
…variables, and redundant null checks

Co-authored-by: jeanlrnt <[email protected]>
Refactor: Invoke JobRegistry events outside WriteLock to prevent blocking and deadlocks
Copilot AI review requested due to automatic review settings January 2, 2026 13:01
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR refactors the JobRegistry class to invoke events (JobAdded, JobRemoved, JobUpdated) outside of write locks, improving concurrency by allowing read operations to proceed while event handlers are executing. This prevents long-running event handlers from blocking registry operations.

Key changes:

  • Event invocations moved outside write locks in ScheduleJob, RemoveJob, and UpdateSchedule methods
  • Event arguments are prepared inside the lock, then events are invoked after releasing the lock
  • Documentation updated to reflect that events are now "raised after the write lock is released"

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
src/MiniCron.Core/Services/JobRegistry.cs Refactored all three registry modification methods to prepare event arguments within the write lock, then invoke events outside the lock; updated XML documentation to reflect the new behavior
src/MiniCron.Tests/MiniCronTests.EventInvocationOutsideLock.cs Added comprehensive test suite verifying events are invoked outside locks, allowing concurrent reads, handling exceptions gracefully, preventing deadlocks on reentrant calls, and validating event argument correctness

@jeanlrnt jeanlrnt merged commit 586036c into main Jan 2, 2026
11 checks passed
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