Skip to content

Commit

Permalink
ForceRelease now releases everything in the semaphore before removing…
Browse files Browse the repository at this point in the history
… the key from the dictionary.
  • Loading branch information
MarkCiliaVincenti committed Oct 18, 2022
1 parent 4bcf117 commit 64f70e2
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions AsyncKeyedLock.Tests/AsyncKeyedLock.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
Expand All @@ -9,7 +9,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="AsyncKeyedLock" Version="3.0.0" />
<PackageReference Include="AsyncKeyedLock" Version="3.0.1" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.3.2" />
<PackageReference Include="xunit" Version="2.4.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.5">
Expand Down
8 changes: 4 additions & 4 deletions AsyncKeyedLock/AsyncKeyedLock.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
<RepositoryUrl>https://github.com/MarkCiliaVincenti/AsyncKeyedLock.git</RepositoryUrl>
<PackageProjectUrl>https://github.com/MarkCiliaVincenti/AsyncKeyedLock</PackageProjectUrl>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<Version>3.0.0</Version>
<Version>3.0.1</Version>
<PackageIcon>logo.png</PackageIcon>
<PackageReleaseNotes>Fixed serious issue with concurrent threads having been limited to 1 irrespective of setting in the constructor. Also added a few features and tests.</PackageReleaseNotes>
<PackageReleaseNotes>ForceRelease now releases everything in the semaphore before removing the key from the dictionary.</PackageReleaseNotes>
<Description>An asynchronous .NET Standard 2.0 library that allows you to lock based on a key (keyed semaphores), only allowing a defined number of concurrent threads that share the same key.</Description>
<Copyright>© 2022 Mark Cilia Vincenti</Copyright>
<PackageTags>async,lock,key,semaphore,dictionary</PackageTags>
<RepositoryType>git</RepositoryType>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<FileVersion>3.0.0.0</FileVersion>
<AssemblyVersion>3.0.1.0</AssemblyVersion>
<FileVersion>3.0.1.0</FileVersion>
<PackageReadmeFile>README.md</PackageReadmeFile>
<IsPackable>true</IsPackable>
<IsTrimmable>true</IsTrimmable>
Expand Down
7 changes: 6 additions & 1 deletion AsyncKeyedLock/AsyncKeyedLocker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ public bool ForceRelease(object key)
{
lock (SemaphoreSlims)
{
return SemaphoreSlims.Remove(key);
if (SemaphoreSlims.TryGetValue(key, out var referenceCounter))
{
referenceCounter.Value.Release(referenceCounter.ReferenceCount);
return SemaphoreSlims.Remove(key);
}
return false;
}
}
}
Expand Down

0 comments on commit 64f70e2

Please sign in to comment.