Skip to content

Commit

Permalink
don't persist in main thread
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojciech Turowicz committed Sep 1, 2023
1 parent 492adad commit 549d67a
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/Orleans.Streaming.Grains/Grains/TransactionGrain.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ public async Task CompleteAsync(Guid id, bool success)
State.Poison.Enqueue(id);
}

await PersistAsync();

if (_subscriptions.Any())
{
await _subscriptions.Notify(x => x.CompletedAsync(id, success, this.GetPrimaryKeyString()));
}
}
}

public async Task<Guid?> PopAsync()
public Task<Guid?> PopAsync()
{
if (State.Queue.TryDequeue(out var id))
{
Expand All @@ -86,19 +84,17 @@ public async Task CompleteAsync(Guid id, bool success)
});
}

await PersistAsync();

return id;
return Task.FromResult(new Guid?(id));
}

return null;
return Task.FromResult(default(Guid?));
}

public async Task PostAsync(Guid id)
public Task PostAsync(Guid id)
{
State.Queue.Enqueue(id);

await PersistAsync();
return Task.CompletedTask;
}

public Task<TransactionGrainState> GetStateAsync()
Expand Down Expand Up @@ -139,9 +135,9 @@ public async Task FlushAsync()
State.Queue.Enqueue(item.Key);
}
}

await PersistAsync();
}

await PersistAsync();
}

private async Task FlushTimerAsync(object arg)
Expand Down

0 comments on commit 549d67a

Please sign in to comment.