From 60069195aec2d096673c9d836994d8ccd6febe18 Mon Sep 17 00:00:00 2001 From: Timon Date: Tue, 10 Oct 2023 22:46:39 +0000 Subject: [PATCH] refactored StructuredAsyncLock --- MemoizR.AsyncLock/MemoizR.AsyncLock.csproj | 13 -------- .../AsyncAsymmetricLock.cs | 2 +- .../MemoizR.StructuredAsyncLock.csproj | 32 +++++++++++++++++++ .../Nito/AsyncWaitQueue.cs | 2 +- .../Nito/AwaitableDisposable.cs | 2 +- .../Nito/TaskCompletionSourceExtensions.cs | 2 +- MemoizR.sln | 2 +- MemoizR/Context.cs | 2 +- MemoizR/MemoizR.csproj | 2 +- MemoizR/Signal.cs | 2 -- docs/NUGET_ASYNC_LOCK_README.md | 6 ++++ 11 files changed, 45 insertions(+), 22 deletions(-) delete mode 100644 MemoizR.AsyncLock/MemoizR.AsyncLock.csproj rename {MemoizR.AsyncLock => MemoizR.StructuredAsyncLock}/AsyncAsymmetricLock.cs (99%) create mode 100644 MemoizR.StructuredAsyncLock/MemoizR.StructuredAsyncLock.csproj rename {MemoizR.AsyncLock => MemoizR.StructuredAsyncLock}/Nito/AsyncWaitQueue.cs (99%) rename {MemoizR.AsyncLock => MemoizR.StructuredAsyncLock}/Nito/AwaitableDisposable.cs (98%) rename {MemoizR.AsyncLock => MemoizR.StructuredAsyncLock}/Nito/TaskCompletionSourceExtensions.cs (99%) create mode 100644 docs/NUGET_ASYNC_LOCK_README.md diff --git a/MemoizR.AsyncLock/MemoizR.AsyncLock.csproj b/MemoizR.AsyncLock/MemoizR.AsyncLock.csproj deleted file mode 100644 index 14fa2c3..0000000 --- a/MemoizR.AsyncLock/MemoizR.AsyncLock.csproj +++ /dev/null @@ -1,13 +0,0 @@ - - - - net7.0 - enable - enable - - - - - - - diff --git a/MemoizR.AsyncLock/AsyncAsymmetricLock.cs b/MemoizR.StructuredAsyncLock/AsyncAsymmetricLock.cs similarity index 99% rename from MemoizR.AsyncLock/AsyncAsymmetricLock.cs rename to MemoizR.StructuredAsyncLock/AsyncAsymmetricLock.cs index aa2a243..249fa60 100644 --- a/MemoizR.AsyncLock/AsyncAsymmetricLock.cs +++ b/MemoizR.StructuredAsyncLock/AsyncAsymmetricLock.cs @@ -1,4 +1,4 @@ -namespace MemoizR.AsyncLock; +namespace MemoizR.StructuredAsyncLock; public class AsyncAsymmetricLock { diff --git a/MemoizR.StructuredAsyncLock/MemoizR.StructuredAsyncLock.csproj b/MemoizR.StructuredAsyncLock/MemoizR.StructuredAsyncLock.csproj new file mode 100644 index 0000000..069b1fa --- /dev/null +++ b/MemoizR.StructuredAsyncLock/MemoizR.StructuredAsyncLock.csproj @@ -0,0 +1,32 @@ + + + net7.0 + MemoizR.StructuredAsyncLock + 0.0.5 + Timon Krebs + Apache-2.0 + enable + enable + NUGET_ASYNC_LOCK_README.md + MemoizR-Small.png + + true + + + true + + + true + snupkg + Memoization, StructuredConcurrency, Structured Concurrency, Graph, Dependency, Dependencies, Dynamic, Dynamic Dependencies, Concurrency, Lazy, Resolve, Perf, Performance, Parallel, Parallel Computing, Sync, Synchronization, State, State Synchronization + + + + + + + + + + + diff --git a/MemoizR.AsyncLock/Nito/AsyncWaitQueue.cs b/MemoizR.StructuredAsyncLock/Nito/AsyncWaitQueue.cs similarity index 99% rename from MemoizR.AsyncLock/Nito/AsyncWaitQueue.cs rename to MemoizR.StructuredAsyncLock/Nito/AsyncWaitQueue.cs index 4bc1554..da1b70e 100644 --- a/MemoizR.AsyncLock/Nito/AsyncWaitQueue.cs +++ b/MemoizR.StructuredAsyncLock/Nito/AsyncWaitQueue.cs @@ -1,7 +1,7 @@ using System.Diagnostics; using Nito.Collections; -namespace MemoizR.AsyncLock; +namespace MemoizR.StructuredAsyncLock; /// /// A collection of cancelable instances. Implementations must assume the caller is holding a lock. diff --git a/MemoizR.AsyncLock/Nito/AwaitableDisposable.cs b/MemoizR.StructuredAsyncLock/Nito/AwaitableDisposable.cs similarity index 98% rename from MemoizR.AsyncLock/Nito/AwaitableDisposable.cs rename to MemoizR.StructuredAsyncLock/Nito/AwaitableDisposable.cs index d0abd65..b8629fa 100644 --- a/MemoizR.AsyncLock/Nito/AwaitableDisposable.cs +++ b/MemoizR.StructuredAsyncLock/Nito/AwaitableDisposable.cs @@ -1,6 +1,6 @@ using System.Runtime.CompilerServices; -namespace MemoizR.AsyncLock; +namespace MemoizR.StructuredAsyncLock; /// /// An awaitable wrapper around a task whose result is disposable. The wrapper is not disposable, so this prevents usage errors like "using (MyAsync())" when the appropriate usage should be "using (await MyAsync())". diff --git a/MemoizR.AsyncLock/Nito/TaskCompletionSourceExtensions.cs b/MemoizR.StructuredAsyncLock/Nito/TaskCompletionSourceExtensions.cs similarity index 99% rename from MemoizR.AsyncLock/Nito/TaskCompletionSourceExtensions.cs rename to MemoizR.StructuredAsyncLock/Nito/TaskCompletionSourceExtensions.cs index a63b1f4..648ab2c 100644 --- a/MemoizR.AsyncLock/Nito/TaskCompletionSourceExtensions.cs +++ b/MemoizR.StructuredAsyncLock/Nito/TaskCompletionSourceExtensions.cs @@ -1,4 +1,4 @@ -namespace MemoizR.AsyncLock; +namespace MemoizR.StructuredAsyncLock; /// /// Provides extension methods for . diff --git a/MemoizR.sln b/MemoizR.sln index db43246..06b5cfb 100644 --- a/MemoizR.sln +++ b/MemoizR.sln @@ -11,7 +11,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoizR.Reactive", "MemoizR EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoizR.StructuredConcurrency", "MemoizR.StructuredConcurrency\MemoizR.StructuredConcurrency.csproj", "{565C60BC-380D-4E30-B621-A31C5E229A7F}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoizR.AsyncLock", "MemoizR.AsyncLock\MemoizR.AsyncLock.csproj", "{412EE767-E418-4103-B4B1-4D61A2D91D13}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MemoizR.StructuredAsyncLock", "MemoizR.StructuredAsyncLock\MemoizR.StructuredAsyncLock.csproj", "{412EE767-E418-4103-B4B1-4D61A2D91D13}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/MemoizR/Context.cs b/MemoizR/Context.cs index 87ffb5f..3f0ad8e 100644 --- a/MemoizR/Context.cs +++ b/MemoizR/Context.cs @@ -1,4 +1,4 @@ -using MemoizR.AsyncLock; +using MemoizR.StructuredAsyncLock; namespace MemoizR; diff --git a/MemoizR/MemoizR.csproj b/MemoizR/MemoizR.csproj index bed8e3d..6aa830e 100644 --- a/MemoizR/MemoizR.csproj +++ b/MemoizR/MemoizR.csproj @@ -1,7 +1,7 @@ - + diff --git a/MemoizR/Signal.cs b/MemoizR/Signal.cs index ed6a11c..c4ab7cd 100644 --- a/MemoizR/Signal.cs +++ b/MemoizR/Signal.cs @@ -1,5 +1,3 @@ -using MemoizR.AsyncLock; - namespace MemoizR; public sealed class Signal : MemoHandlR diff --git a/docs/NUGET_ASYNC_LOCK_README.md b/docs/NUGET_ASYNC_LOCK_README.md new file mode 100644 index 0000000..9c15b9c --- /dev/null +++ b/docs/NUGET_ASYNC_LOCK_README.md @@ -0,0 +1,6 @@ +# MemoizR:AsyncLock + +AsyncAsymmetricLock should only be used in accordance with structured sequential concurrency. +No Task should be stored in a variable to ensure structured sequential concurrency. + +Otherwise it there will be undefined behaviour. \ No newline at end of file