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

Ensure proper threads for InterProcessMutex #552

Merged
merged 2 commits into from
Sep 23, 2024

Conversation

AndrewWestberg
Copy link
Member

The way coroutines work, it's possible to resume on a different thread after a suspend function. This creates an extension function so we can use InterProcessMutex with coroutines to ensure we resume on the same physical JVM thread. This allows us to confidently release() the interprocess mutex since it will be acquired and released on the same physical JVM thread.

Copy link

@escobarjonatan escobarjonatan left a comment

Choose a reason for hiding this comment

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

🔥

@AndrewWestberg AndrewWestberg merged commit a33dab0 into master Sep 23, 2024
2 checks passed
@AndrewWestberg AndrewWestberg deleted the amw/interprocessmutex_coroutines branch September 23, 2024 20:46
// This extension function ensures that the block() is executed on the same thread as the lock and
// releases the lock after the block is executed on the same thread.

@OptIn(ExperimentalCoroutinesApi::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we still be using ExperimentalCoroutinesApi ? Curious if we need to update kotlin versions

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.

4 participants