diff --git a/ZeroLevel.UnitTests/DumpTests.cs b/ZeroLevel.UnitTests/DumpTests.cs index f839d91..8bbf35a 100644 --- a/ZeroLevel.UnitTests/DumpTests.cs +++ b/ZeroLevel.UnitTests/DumpTests.cs @@ -1,10 +1,4 @@ -using System; -using System.Linq; -using Xunit; -using ZeroLevel.Services.Microservices.Dump; -using ZeroLevel.UnitTests.Models; - -namespace ZeroLevel.UnitTests +namespace ZeroLevel.UnitTests { // In developing, not working! public class DumpTests diff --git a/ZeroLevel/Services/Utils/MultiHandler.cs b/ZeroLevel/Services/Utils/MultiHandler.cs deleted file mode 100644 index 7bc649c..0000000 --- a/ZeroLevel/Services/Utils/MultiHandler.cs +++ /dev/null @@ -1,87 +0,0 @@ -using System; -using System.Linq; -using System.Collections.Generic; -using System.Threading; -using ZeroLevel.Services.Collections; -using System.Collections.Concurrent; - -namespace ZeroLevel.Services.Utils -{ - public class MultiHandler - : IDisposable - { - private class Executor - { - public Thread Thread; - public Action Handle; - public Func Count; - public bool Canceled; - } - - private RoundRobinCollection _handlers = new RoundRobinCollection(); - private readonly object _lock_handlers = new object(); - - public MultiHandler(Action handler, int size) - { - for (int i = 0; i < size; i++) - { - var t = new Thread((s) => - { - var queue = new BlockingCollection(); - var executor = new Executor - { - Handle = data => - { - queue.Add(data); - }, - Count = () => queue.Count, - Thread = Thread.CurrentThread, - Canceled = false - }; - lock (_lock_handlers) - { - ((RoundRobinCollection)s).Add(executor); - } - try - { - while (!executor.Canceled) - { - T obj; - if (queue.TryTake(out obj, 500)) - { - handler(obj); - } - } - queue.Dispose(); - } - catch (Exception ex) - { - Log.Error(ex, "[MultiHandler] Loop fault"); - } - }); - t.IsBackground = true; - t.Start(_handlers); - } - } - - public void Append(T t) - { - _handlers.MoveNextAndHandle(h => h.Handle(t)); - } - - private int Count => _handlers.Source.Sum(h => h.Count()); - - public void WaitForEmpty() - { - while (Count > 0) - { - Thread.Sleep(300); - } - } - - public void Dispose() - { - foreach (var h in _handlers.Source) h.Canceled = true; - } - } -} diff --git a/ZeroLevel/ZeroLevel.csproj b/ZeroLevel/ZeroLevel.csproj index 89bf9c4..a512066 100644 --- a/ZeroLevel/ZeroLevel.csproj +++ b/ZeroLevel/ZeroLevel.csproj @@ -2,20 +2,20 @@ netstandard2.0 - Infrastructure layer tools set. + Infrastructure layer tool set. ogoun ogoun - 3.1.8.0 - Fixing and extending + 3.1.9.0 + Fix bugs, append Multiprocessor class https://github.com/ogoun/Zero/wiki - Copyright Ogoun 2019 + Copyright Ogoun 2020 https://raw.githubusercontent.com/ogoun/Zero/master/zero.png https://github.com/ogoun/Zero GitHub - 3.1.8 - 3.1.8.0 + 3.1.9 + 3.1.9.0 AnyCPU;x64