|
|
@ -22,6 +22,7 @@ namespace Squidex.Infrastructure.EventSourcing.Grains |
|
|
private readonly IEventDataFormatter eventDataFormatter; |
|
|
private readonly IEventDataFormatter eventDataFormatter; |
|
|
private readonly IEventStore eventStore; |
|
|
private readonly IEventStore eventStore; |
|
|
private readonly ISemanticLog log; |
|
|
private readonly ISemanticLog log; |
|
|
|
|
|
private readonly SemaphoreSlim semaphore = new SemaphoreSlim(1); |
|
|
private TaskScheduler? scheduler; |
|
|
private TaskScheduler? scheduler; |
|
|
private BatchSubscriber? currentSubscriber; |
|
|
private BatchSubscriber? currentSubscriber; |
|
|
private IEventConsumer? eventConsumer; |
|
|
private IEventConsumer? eventConsumer; |
|
|
@ -196,6 +197,9 @@ namespace Squidex.Infrastructure.EventSourcing.Grains |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private async Task DoAndUpdateStateAsync(Func<Task> action, [CallerMemberName] string? caller = null) |
|
|
private async Task DoAndUpdateStateAsync(Func<Task> action, [CallerMemberName] string? caller = null) |
|
|
|
|
|
{ |
|
|
|
|
|
await semaphore.WaitAsync(); |
|
|
|
|
|
try |
|
|
{ |
|
|
{ |
|
|
var previousState = State; |
|
|
var previousState = State; |
|
|
|
|
|
|
|
|
@ -227,6 +231,11 @@ namespace Squidex.Infrastructure.EventSourcing.Grains |
|
|
await state.WriteAsync(); |
|
|
await state.WriteAsync(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
finally |
|
|
|
|
|
{ |
|
|
|
|
|
semaphore.Release(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private async Task ClearAsync() |
|
|
private async Task ClearAsync() |
|
|
{ |
|
|
{ |
|
|
|