Refactor subscriptions manager

This commit is contained in:
Christian
2018-05-03 22:22:07 +02:00
parent d14088512b
commit b22b02a0b6
12 changed files with 269 additions and 107 deletions
@@ -0,0 +1,26 @@
using System;
using System.Threading;
using System.Threading.Tasks;
namespace MQTTnet.Internal
{
public sealed class AsyncLock : IDisposable
{
private readonly SemaphoreSlim _semaphore = new SemaphoreSlim(1, 1);
public Task EnterAsync(CancellationToken cancellationToken)
{
return _semaphore.WaitAsync(cancellationToken);
}
public void Exit()
{
_semaphore.Release();
}
public void Dispose()
{
_semaphore?.Dispose();
}
}
}