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

Add Temporalio.Workflows.Mutex #298

Merged
merged 3 commits into from
Jul 2, 2024
Merged

Add Temporalio.Workflows.Mutex #298

merged 3 commits into from
Jul 2, 2024

Conversation

cretz
Copy link
Member

@cretz cretz commented Jul 1, 2024

What was changed

Added Temporalio.Workflows.Mutex which is a thin layer over the semaphore

  1. Closes [Feature Request] Add Temporalio.Workflows.Mutex as thin facade over single-count Temporalio.Workflows.Semaphore #297

@cretz cretz requested a review from a team July 1, 2024 21:37
Copy link
Member

@Sushisource Sushisource left a comment

Choose a reason for hiding this comment

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

Would it make sense to add support for using this withing a using block? Seems like that could be nice.

src/Temporalio/Workflows/Mutex.cs Outdated Show resolved Hide resolved
@cretz
Copy link
Member Author

cretz commented Jul 2, 2024

Would it make sense to add support for using this withing a using block

In this case we are matching existing .NET APIs which do not leverage IDisposable to release mutexes/semaphores. I think .NET chose explicit release vs using block (akin to a Rust guard) for .NET developers to be clear about when to release (may not otherwise be clear especially for those with using as a statement instead of a block).

Copy link
Contributor

@dandavison dandavison left a comment

Choose a reason for hiding this comment

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

LGTM!

@cretz cretz merged commit 8349537 into temporalio:main Jul 2, 2024
7 checks passed
@cretz cretz deleted the mutex branch July 2, 2024 13:07
@Sushisource
Copy link
Member

Would it make sense to add support for using this withing a using block

In this case we are matching existing .NET APIs which do not leverage IDisposable to release mutexes/semaphores. I think .NET chose explicit release vs using block (akin to a Rust guard) for .NET developers to be clear about when to release (may not otherwise be clear especially for those with using as a statement instead of a block).

FYI it very much does work with disposable https://learn.microsoft.com/en-us/dotnet/api/system.threading.mutex?view=net-8.0#remarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants