Skip to content

Commit 3f59902

Browse files
committed
Nito -> AsyncLock
1 parent 65f19ea commit 3f59902

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

src/AsyncSingleton{T,T1}.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using Nito.AsyncEx;
2-
using Soenneker.Atomics.ValueBools;
1+
using Soenneker.Atomics.ValueBools;
32
using Soenneker.Extensions.ValueTask;
43
using Soenneker.Utils.AsyncSingleton.Abstract;
54
using System;
65
using System.Threading;
76
using System.Threading.Tasks;
7+
using Soenneker.Asyncs.Locks;
88

99
namespace Soenneker.Utils.AsyncSingleton;
1010

@@ -54,7 +54,7 @@ private ValueTask<T> GetOrCreate(CancellationToken ct, T1 arg)
5454

5555
async ValueTask<T> Slow(CancellationToken token, T1 a)
5656
{
57-
using (await _lock.LockAsync(token).ConfigureAwait(false))
57+
using (await _lock.Lock(token).NoSync())
5858
{
5959
if (_disposed.Value)
6060
throw new ObjectDisposedException(typeof(AsyncSingleton<T, T1>).Name);
@@ -80,7 +80,7 @@ public T GetSync(T1 arg, CancellationToken cancellationToken = default)
8080
if (_hasValue.Value)
8181
return _instance!;
8282

83-
using (_lock.Lock())
83+
using (_lock.LockSync())
8484
{
8585
if (_disposed.Value)
8686
throw new ObjectDisposedException(typeof(AsyncSingleton<T, T1>).Name);
@@ -138,7 +138,7 @@ public void Dispose()
138138

139139
object? local;
140140

141-
using (_lock.Lock())
141+
using (_lock.LockSync())
142142
{
143143
_hasValue.Value = false;
144144
local = _instance;
@@ -160,7 +160,7 @@ public async ValueTask DisposeAsync()
160160

161161
object? local;
162162

163-
using (await _lock.LockAsync().ConfigureAwait(false))
163+
using (await _lock.Lock().NoSync())
164164
{
165165
_hasValue.Value = false;
166166
local = _instance;

src/AsyncSingleton{T}.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using Nito.AsyncEx;
2-
using Soenneker.Atomics.ValueBools;
1+
using Soenneker.Atomics.ValueBools;
32
using Soenneker.Extensions.ValueTask;
43
using Soenneker.Utils.AsyncSingleton.Abstract;
54
using System;
65
using System.Threading;
76
using System.Threading.Tasks;
7+
using Soenneker.Asyncs.Locks;
88

99
namespace Soenneker.Utils.AsyncSingleton;
1010

@@ -54,7 +54,7 @@ public virtual ValueTask<T> GetOrCreate(CancellationToken cancellationToken = de
5454

5555
async ValueTask<T> Slow(CancellationToken ct)
5656
{
57-
using (await _lock.LockAsync(ct).ConfigureAwait(false))
57+
using (await _lock.Lock(ct).NoSync())
5858
{
5959
if (_disposed.Value)
6060
throw new ObjectDisposedException(typeof(AsyncSingleton<T>).Name);
@@ -80,7 +80,7 @@ public T GetSync(CancellationToken cancellationToken = default)
8080
if (_hasValue.Value)
8181
return (T)_instance!;
8282

83-
using (_lock.Lock())
83+
using (_lock.LockSync())
8484
{
8585
if (_disposed.Value)
8686
throw new ObjectDisposedException(typeof(AsyncSingleton<T>).Name);
@@ -138,7 +138,7 @@ public void Dispose()
138138

139139
object? local;
140140

141-
using (_lock.Lock())
141+
using (_lock.LockSync())
142142
{
143143
_hasValue.Value = false;
144144
local = _instance;
@@ -161,7 +161,7 @@ public async ValueTask DisposeAsync()
161161

162162
object? local;
163163

164-
using (await _lock.LockAsync().ConfigureAwait(false))
164+
using (await _lock.Lock().NoSync())
165165
{
166166
_hasValue.Value = false;
167167
local = _instance;

src/Soenneker.Utils.AsyncSingleton.csproj

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?xml version="1.0" encoding="utf-8"?><Project Sdk="Microsoft.NET.Sdk">
1+
<?xml version="1.0" encoding="utf-8"?>
2+
3+
<Project Sdk="Microsoft.NET.Sdk">
24

35
<PropertyGroup>
46
<TargetFramework>net10.0</TargetFramework>
@@ -30,23 +32,17 @@
3032
<LangVersion>latest</LangVersion>
3133
<PackageReadmeFile>README.md</PackageReadmeFile>
3234
<PackageIcon>icon.png</PackageIcon>
33-
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild></PropertyGroup>
35+
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
36+
</PropertyGroup>
3437

35-
<ItemGroup>
36-
<Compile Remove="NewFolder\**" />
37-
<EmbeddedResource Remove="NewFolder\**" />
38-
<None Remove="NewFolder\**" />
39-
</ItemGroup>
40-
4138
<ItemGroup>
4239
<None Include="..\README.md" Pack="true" PackagePath="\" />
4340
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
4441
<None Include="..\icon.png" Pack="true" PackagePath="\" />
4542
</ItemGroup>
4643

4744
<ItemGroup>
48-
<PackageReference Include="Nito.AsyncEx" Version="5.1.2" />
49-
<PackageReference Include="Soenneker.Atomics.ValueBools" Version="4.0.3" />
50-
<PackageReference Include="Soenneker.Extensions.ValueTask" Version="4.0.97" />
45+
<PackageReference Include="Soenneker.Asyncs.Locks" Version="4.0.1" />
46+
<PackageReference Include="Soenneker.Extensions.ValueTask" Version="4.0.98" />
5147
</ItemGroup>
52-
</Project>
48+
</Project>

0 commit comments

Comments
 (0)