Skip to content

Commit

Permalink
1.0.19-beta: Concurrency issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
adospace committed Jun 27, 2024
1 parent ef08bea commit 0b57ea9
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

env:
Solution_Name: ./src/ReactorData.sln
Version: 1.0.18-beta
Version: 1.0.19-beta

steps:
- name: Checkout
Expand Down
9 changes: 4 additions & 5 deletions src/ReactorData/Implementation/ModelContext.Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ internal override async ValueTask Do(ModelContext context)
}
else
{
set.Add(entityKey, entity);
set.TryAdd(entityKey, entity);
}

queryTypesToNofity.Add(entityType);
Expand Down Expand Up @@ -253,9 +253,8 @@ internal override ValueTask Do(ModelContext context)
{
HashSet<Type> queryTypesToNofity = [];
HashSet<IEntity> changedEntities = [];
ConcurrentDictionary<Type, HashSet<IEntity>> entitiesChanged = [];

foreach (var (Entity, Status) in context._operationQueue)
foreach (var (Entity, _) in context._operationQueue)
{
changedEntities.Add(Entity);

Expand All @@ -268,7 +267,7 @@ internal override ValueTask Do(ModelContext context)

foreach (var queryTypeToNofity in queryTypesToNofity)
{
context.NotifyChanges(queryTypeToNofity, changedEntities.ToArray());
context.NotifyChanges(queryTypeToNofity, [.. changedEntities]);
}

return ValueTask.CompletedTask;
Expand Down Expand Up @@ -362,7 +361,7 @@ internal override async ValueTask Do(ModelContext context)
case EntityStatus.Deleted:
{
var set = context._sets.GetOrAdd(Entity.GetType(), []);
set.Remove(Entity.GetKey().EnsureNotNull());
set.TryRemove(Entity.GetKey().EnsureNotNull(), out var _);

queryTypesToNofity.Add(Entity.GetType());
}
Expand Down
2 changes: 1 addition & 1 deletion src/ReactorData/Implementation/ModelContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace ReactorData.Implementation;

partial class ModelContext : IModelContext
{
private readonly ConcurrentDictionary<Type, Dictionary<object, IEntity>> _sets = [];
private readonly ConcurrentDictionary<Type, ConcurrentDictionary<object, IEntity>> _sets = [];

private readonly Queue<(IEntity Entity, EntityStatus Status)> _operationQueue = [];

Expand Down

0 comments on commit 0b57ea9

Please sign in to comment.