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

Services #1163

Merged
merged 2 commits into from
Nov 13, 2024
Merged

Services #1163

merged 2 commits into from
Nov 13, 2024

Conversation

jaakkonakaza
Copy link
Member

Don't allow running multiple instances of some services at once and add better error handling for module imports

Fixes #1153 (hopefully)

@jaakkonakaza jaakkonakaza marked this pull request as ready for review November 13, 2024 12:11
@OlliKiljunen OlliKiljunen self-requested a review November 13, 2024 12:12
Copy link
Member

@OlliKiljunen OlliKiljunen left a comment

Choose a reason for hiding this comment

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

Good work!

I would prefer seeing synchronization handled more separately from the business logic (something similar to what is tried to do [here](https://stackoverflow.com/questions/71038075/launch-one-coroutine-at-a-time-kotlin perhaps giving a Mutex object as a parameter for "launchWithMutex" method) but how it's handled here is ok, I think.

fun importModules() {
if (!running.compareAndSet(false, true)) {
Copy link
Member

Choose a reason for hiding this comment

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

Consider using Mutex.tryLock instead of AtomicBoolean.compareAndSet. While the functional difference (that is, I think, Mutex ensures happens-before relationships between the occasions it's locked) doesn't necessarily matter here, it would make it more clear that this is about synchronizing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will do this in the next update

@jaakkonakaza jaakkonakaza merged commit e102c4e into main Nov 13, 2024
6 of 8 checks passed
@jaakkonakaza jaakkonakaza deleted the services branch November 13, 2024 13:21
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.

Double submissions: plugin accidentally submits a solution twice
2 participants