You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Zero/TestApp/Program.cs

63 lines
1.4 KiB

2 years ago
using System;
1 year ago
using System.Collections.Concurrent;
using System.Linq;
using System.Reflection;
1 year ago
using ZeroLevel.Logging;
using ZeroLevel.Services.Invokation;
using ZeroLevel.Services.Serialization;
2 years ago
namespace TestApp
{
1 year ago
public record LogMessage<T>(LogLevel Level, T Message);
internal interface ILogMessageBuffer<T>
: IDisposable
{
long Count();
void Push(LogLevel level, T message);
LogMessage<T> Take();
}
internal sealed class NoLimitedLogMessageBuffer<T>
: ILogMessageBuffer<T>
{
1 year ago
private readonly BlockingCollection<LogMessage<T>> _messageQueue =
new BlockingCollection<LogMessage<T>>();
private bool _isDisposed = false;
public long Count()
{
1 year ago
if (_messageQueue.IsCompleted)
return 0;
return _messageQueue.Count;
}
1 year ago
public void Dispose()
{
if (!_isDisposed)
{
1 year ago
_isDisposed = true;
_messageQueue.Dispose();
}
1 year ago
}
public void Push(LogLevel level, T message)
{
if (_isDisposed) return;
_messageQueue.Add(new LogMessage<T>(level, message));
}
public LogMessage<T> Take()
{
return _messageQueue.Take();
}
}
internal static class Program
{
1 year ago
private static void Main(string[] args)
{
3 years ago
}
}
5 years ago
}

Powered by TurnKey Linux.