Skip to content

Commit f2eba4d

Browse files
committed
Refactoring.
Version 0.0.4.
1 parent 13e7155 commit f2eba4d

File tree

7 files changed

+28
-19
lines changed

7 files changed

+28
-19
lines changed

ConcurrentQueueExtensions.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,17 @@ public static class ConcurrentQueueExtensions
1010
public static async Task AwaitAll(this ConcurrentQueue<Task> queue)
1111
{
1212
foreach (var item in queue.DequeueAll())
13+
{
1314
await item;
15+
}
1416
}
1517

1618
public static async Task AwaitOne(this ConcurrentQueue<Task> queue)
1719
{
1820
if (queue.TryDequeue(out Task item))
21+
{
1922
await item;
23+
}
2024
}
2125

2226
public static void EnqueueAsRunnedTask(this ConcurrentQueue<Task> queue, Action action) => queue.Enqueue(Task.Run(action));

Platform.Threading.csproj

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<Description>LinksPlatform's Platform.Threading Class Library</Description>
55
<Copyright>Konstantin Diachenko</Copyright>
66
<AssemblyTitle>Platform.Threading</AssemblyTitle>
7-
<VersionPrefix>0.0.3</VersionPrefix>
7+
<VersionPrefix>0.0.4</VersionPrefix>
88
<Authors>Konstantin Diachenko</Authors>
99
<TargetFramework>netstandard2.0</TargetFramework>
1010
<AssemblyName>Platform.Threading</AssemblyName>
@@ -21,6 +21,8 @@
2121
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
2222
<IncludeSymbols>true</IncludeSymbols>
2323
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
24+
<PackageReleaseNotes>Platform.Collections updated to 0.0.3 version.
25+
Refactoring.</PackageReleaseNotes>
2426
</PropertyGroup>
2527

2628
<ItemGroup>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ LinksPlatform's Platform.Threading Class Library.
66

77
Namespace: Platform.Threading
88

9-
Forked from: https://github.com/Konard/LinksPlatform/tree/b41aac7909066bb746c7f8e29a1cd59710e5b0d5/Platform/Platform.Helpers/Threading
9+
Forked from: [Konard/LinksPlatform/Platform/Platform.Helpers/Threading](https://github.com/Konard/LinksPlatform/tree/b41aac7909066bb746c7f8e29a1cd59710e5b0d5/Platform/Platform.Helpers/Threading)
1010

11-
NuGet package: https://www.nuget.org/packages/Platform.Threading
11+
NuGet package: [Platform.Threading](https://www.nuget.org/packages/Platform.Threading)

Synchronization/ISynchronized.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
namespace Platform.Threading.Synchronization
22
{
33
/// <summary>
4-
/// Represents extendable sychronized interface access gate.
4+
/// Represents extendable synchronized interface access gate.
5+
/// Представляет расширяемый интерфейс шлюза синхронизированного доступа.
56
/// </summary>
6-
/// <typeparam name="TInterface">Sychronized interface.</typeparam>
7-
public interface ISynchronized<TInterface>
7+
/// <typeparam name="TInterface">Synchronized interface. Синхронизируемый интерфейс.</typeparam>
8+
public interface ISynchronized<out TInterface>
89
{
910
/// <summary>
1011
/// Gets sychronization method.

Synchronization/ReaderWriterLockSynchronization.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@
33

44
namespace Platform.Threading.Synchronization
55
{
6-
/// <summary>
7-
/// TODO: Сравнить что производительнее использовать анонимную функцию или using (создание объекта + dispose)
8-
/// </summary>
96
public class ReaderWriterLockSynchronization : ISynchronization
107
{
118
private readonly ReaderWriterLockSlim _rwLock = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

Synchronization/SynchronizationExtensions.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
namespace Platform.Threading.Synchronization
44
{
5-
/// <remarks>
6-
/// TODO: Избавиться от анонимных функций передаваемых в ExecuteReadOperation и ExecureWriteOperation
7-
/// </remarks>
85
public static class SynchronizationExtensions
96
{
107
public static TResult ExecuteReadOperation<TResult, TParam>(this ISynchronization synchronization, TParam parameter, Func<TParam, TResult> function) => synchronization.ExecuteReadOperation(() => function(parameter));

ThreadHelpers.cs

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,30 @@ namespace Platform.Threading
55
{
66
public static class ThreadHelpers
77
{
8-
public const int DefaultMaxStackSize = 0;
9-
public const int DefaultSleepTimeout = 1;
10-
public const int ExtendedMaxStackSize = 200 * 1024 * 1024;
8+
public static readonly int DefaultMaxStackSize = 0;
9+
public static readonly int ExtendedMaxStackSize = 200 * 1024 * 1024;
10+
public static readonly int DefaultSleepTimeout = 1;
1111

12-
public static void SyncInvokeWithExtendedStack<T>(T param, Action<object> action, int maxStackSize = ExtendedMaxStackSize) => StartNew(param, action, maxStackSize).Join();
12+
public static void SyncInvokeWithExtendedStack<T>(T param, Action<object> action) => SyncInvokeWithExtendedStack(param, action, ExtendedMaxStackSize);
1313

14-
public static void SyncInvokeWithExtendedStack(Action action, int maxStackSize = ExtendedMaxStackSize) => StartNew(action, maxStackSize).Join();
14+
public static void SyncInvokeWithExtendedStack<T>(T param, Action<object> action, int maxStackSize) => StartNew(param, action, maxStackSize).Join();
1515

16-
public static Thread StartNew<T>(T param, Action<object> action, int maxStackSize = DefaultMaxStackSize)
16+
public static void SyncInvokeWithExtendedStack(Action action) => SyncInvokeWithExtendedStack(action, ExtendedMaxStackSize);
17+
18+
public static void SyncInvokeWithExtendedStack(Action action, int maxStackSize) => StartNew(action, maxStackSize).Join();
19+
20+
public static Thread StartNew<T>(T param, Action<object> action) => StartNew(param, action, DefaultMaxStackSize);
21+
22+
public static Thread StartNew<T>(T param, Action<object> action, int maxStackSize)
1723
{
1824
var thread = new Thread(new ParameterizedThreadStart(action), maxStackSize);
1925
thread.Start(param);
2026
return thread;
2127
}
2228

23-
public static Thread StartNew(Action action, int maxStackSize = DefaultMaxStackSize)
29+
public static Thread StartNew(Action action) => StartNew(action, DefaultMaxStackSize);
30+
31+
public static Thread StartNew(Action action, int maxStackSize)
2432
{
2533
var thread = new Thread(new ThreadStart(action), maxStackSize);
2634
thread.Start();

0 commit comments

Comments
 (0)