Skip to content

Commit 3c7d1c1

Browse files
committed
Enable ImplicitUsings
1 parent 415911f commit 3c7d1c1

File tree

11 files changed

+18
-349
lines changed

11 files changed

+18
-349
lines changed

src/ImageWizard.Core/Caches/Lock/LocalCacheLock.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,7 @@
22
// https://github.com/usercode/ImageWizard
33
// MIT License
44

5-
using ImageWizard.Core.Locking;
6-
using System;
7-
using System.Collections.Generic;
8-
using System.Linq;
9-
using System.Text;
10-
using System.Threading;
11-
using System.Threading.Tasks;
5+
using AsyncLock;
126

137
namespace ImageWizard.Caches;
148

src/ImageWizard.Core/ImageWizard.Core.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<PropertyGroup>
44
<TargetFramework>net6.0</TargetFramework>
55
<Nullable>enable</Nullable>
6+
<ImplicitUsings>enable</ImplicitUsings>
67
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
78
<Authors>usercode</Authors>
89
<Version>3.7.0</Version>

src/ImageWizard.Core/Locking/AsyncLock.cs

Lines changed: 6 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// Copyright (c) usercode
2-
// https://github.com/usercode/ImageWizard
2+
// https://github.com/usercode/AsyncLock
33
// MIT License
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading;
10-
using System.Threading.Tasks;
11-
12-
namespace ImageWizard.Core.Locking;
5+
namespace AsyncLock;
136

147
/// <summary>
158
/// AsyncLock
@@ -126,65 +119,15 @@ public Task<AsyncLockReleaser> WriterLockAsync(CancellationToken cancellation =
126119
}
127120
}
128121

129-
internal Task<AsyncLockReleaser> SwitchToWriterLockAsync(AsyncLockReleaser releaser, CancellationToken cancellation = default)
130-
{
131-
if (cancellation.IsCancellationRequested)
132-
{
133-
return Task.FromCanceled<AsyncLockReleaser>(cancellation);
134-
}
135-
136-
lock (_syncObj)
137-
{
138-
if (releaser.Type == AsyncLockType.Write)
139-
{
140-
throw new Exception("There is already a writer lock.");
141-
}
142-
143-
var taskWriter = WriterLockAsync(cancellation);
144-
145-
if (releaser.Type != null)
146-
{
147-
Release(releaser.Type.Value, sendReleasedEvent: false);
148-
}
149-
150-
return taskWriter;
151-
}
152-
}
153-
154-
internal Task<AsyncLockReleaser> SwitchToReaderLockAsync(AsyncLockReleaser releaser, bool skipWaitingWriters = false, CancellationToken cancellation = default)
155-
{
156-
if (cancellation.IsCancellationRequested)
157-
{
158-
return Task.FromCanceled<AsyncLockReleaser>(cancellation);
159-
}
160-
161-
lock (_syncObj)
162-
{
163-
if (releaser.Type == AsyncLockType.Read)
164-
{
165-
throw new Exception("There is already a reader lock.");
166-
}
167-
168-
var taskReader = ReaderLockAsync(cancellation);
169-
170-
if (releaser.Type != null)
171-
{
172-
Release(releaser.Type.Value, skipWaitingWriters: skipWaitingWriters, sendReleasedEvent: false);
173-
}
174-
175-
return taskReader;
176-
}
177-
}
178-
179-
internal void Release(AsyncLockType type, bool skipWaitingWriters = false, bool sendReleasedEvent = true)
122+
internal void Release(AsyncLockType type, bool sendReleasedEvent = true)
180123
{
181124
lock (_syncObj)
182125
{
183126
try
184127
{
185128
if (type == AsyncLockType.Write)
186129
{
187-
WriterRelease(skipWaitingWriters);
130+
WriterRelease();
188131
}
189132
else
190133
{
@@ -212,15 +155,10 @@ private void ReaderRelease()
212155
}
213156
}
214157

215-
private void WriterRelease(bool skipWaitingWriters)
158+
private void WriterRelease()
216159
{
217-
_isWriterRunning = false;
218-
219160
//start next writer lock?
220-
if (skipWaitingWriters == false)
221-
{
222-
StartNextWaitingWriter();
223-
}
161+
StartNextWaitingWriter();
224162

225163
//no running writer lock?
226164
if (_isWriterRunning == false)

src/ImageWizard.Core/Locking/AsyncLockReleaser.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// Copyright (c) usercode
2-
// https://github.com/usercode/ImageWizard
2+
// https://github.com/usercode/AsyncLock
33
// MIT License
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
11-
namespace ImageWizard.Core.Locking;
5+
namespace AsyncLock;
126

137
/// <summary>
148
/// AsyncLockReleaser

src/ImageWizard.Core/Locking/AsyncLockState.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// Copyright (c) usercode
2-
// https://github.com/usercode/ImageWizard
2+
// https://github.com/usercode/AsyncLock
33
// MIT License
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
11-
namespace ImageWizard.Core.Locking;
5+
namespace AsyncLock;
126

137
/// <summary>
148
/// AsyncLockState

src/ImageWizard.Core/Locking/AsyncLockType.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,8 @@
11
// Copyright (c) usercode
2-
// https://github.com/usercode/ImageWizard
2+
// https://github.com/usercode/AsyncLock
33
// MIT License
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading.Tasks;
10-
11-
namespace ImageWizard.Core.Locking;
5+
namespace AsyncLock;
126

137
/// <summary>
148
/// AsyncLockType

src/ImageWizard.Core/Locking/AsyncLock~.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// Copyright (c) usercode
2-
// https://github.com/usercode/ImageWizard
2+
// https://github.com/usercode/AsyncLock
33
// MIT License
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading;
10-
using System.Threading.Tasks;
11-
12-
namespace ImageWizard.Core.Locking;
5+
namespace AsyncLock;
136

147
/// <summary>
158
/// AsyncLock

src/ImageWizard.Core/Locking/QueueExtensions.cs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// Copyright (c) usercode
2-
// https://github.com/usercode/ImageWizard
2+
// https://github.com/usercode/AsyncLock
33
// MIT License
44

5-
using System;
6-
using System.Collections.Generic;
7-
using System.Linq;
8-
using System.Text;
9-
using System.Threading;
10-
using System.Threading.Tasks;
11-
12-
namespace ImageWizard.Core.Locking;
5+
namespace AsyncLock;
136

147
public static class QueueExtensions
158
{

src/ImageWizard.Core/Middlewares/ImageWizardApi.cs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
// MIT License
44

55
using ImageWizard.Caches;
6-
using ImageWizard.Core;
7-
using ImageWizard.Core.Locking;
86
using ImageWizard.Loaders;
97
using ImageWizard.Processing;
108
using ImageWizard.Processing.Results;
@@ -16,14 +14,9 @@
1614
using Microsoft.Extensions.Logging;
1715
using Microsoft.Extensions.Options;
1816
using Microsoft.Net.Http.Headers;
19-
using System;
20-
using System.Collections.Generic;
2117
using System.Globalization;
22-
using System.IO;
23-
using System.Linq;
2418
using System.Security.Cryptography;
2519
using System.Text;
26-
using System.Threading.Tasks;
2720

2821
namespace ImageWizard;
2922

src/ImageWizard.Tests/AsyncLockKeyTest.cs

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)