temporalio / sdk-dotnet

Temporal .NET SDK
MIT License
375 stars 30 forks source link

Add Temporalio.Workflows.Mutex #298

Closed cretz closed 2 months ago

cretz commented 2 months ago

What was changed

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

  1. Closes #297
cretz commented 2 months ago

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).

Sushisource commented 2 months ago

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