Browse Source

fix bugs that may have caused leaks

improve throwing of exceptions
tags/2.7
sebas77 6 years ago
parent
commit
fa4087bfa3
9 changed files with 25 additions and 21 deletions
  1. +6
    -6
      Svelto.ECS/Dispatcher/DispatchOnSet.cs
  2. +4
    -0
      Svelto.ECS/EnginesRoot.DoubleBufferedEntityViews.cs
  3. +1
    -1
      Svelto.ECS/EnginesRoot.Entities.cs
  4. +2
    -2
      Svelto.ECS/EnginesRoot.GenericEntityFactory.cs
  5. +7
    -6
      Svelto.ECS/EnginesRoot.Submission.cs
  6. +2
    -2
      Svelto.ECS/EntityViewUtility.cs
  7. +0
    -1
      Svelto.ECS/IEntitiesDB.cs
  8. +1
    -1
      Svelto.ECS/IEntityFactory.cs
  9. +2
    -2
      Svelto.ECS/Sequencer.cs

+ 6
- 6
Svelto.ECS/Dispatcher/DispatchOnSet.cs View File

@@ -23,11 +23,11 @@ namespace Svelto.ECS

_subscribers.Invoke(_senderID, value);
}
}

get
{
return _value;
}
public static implicit operator T(DispatchOnSet<T> dispatch)
{
return dispatch._value;
}
public void NotifyOnValueSet(System.Action<int, T> action)
@@ -40,8 +40,8 @@ namespace Svelto.ECS
_subscribers -= action;
}

protected T _value;
readonly int _senderID;
protected T _value;
readonly int _senderID;

WeakEvent<int, T> _subscribers;
}


+ 4
- 0
Svelto.ECS/EnginesRoot.DoubleBufferedEntityViews.cs View File

@@ -41,7 +41,11 @@ namespace Svelto.ECS
{
subitem.Value.Clear();
}
item.Value.Clear();
}
other.Clear();
}
}
}

+ 1
- 1
Svelto.ECS/EnginesRoot.Entities.cs View File

@@ -87,7 +87,7 @@ namespace Svelto.ECS
{
if (entities.Has(entityID.entityID) == true)
{
Utility.Console.LogError("Entity ".FastConcat(name, " with used ID is about to be built: ")
Svelto.Utilities.Console.LogError("Entity ".FastConcat(name, " with used ID is about to be built: ")
.FastConcat(entityType)
.FastConcat(" id: ")
.FastConcat(entityID.entityID)


+ 2
- 2
Svelto.ECS/EnginesRoot.GenericEntityFactory.cs View File

@@ -25,9 +25,9 @@ namespace Svelto.ECS
return _weakEngine.Target.BuildEntity<T>(egid, implementors);
}

public EntityStructInitializer BuildEntity<T>(EGID egid, T descriptorEntity, object[] implementors) where T:IEntityDescriptor
public EntityStructInitializer BuildEntity<T>(EGID egid, T entityDescriptor, object[] implementors) where T:IEntityDescriptor
{
return _weakEngine.Target.BuildEntity(egid, descriptorEntity, implementors);
return _weakEngine.Target.BuildEntity(egid, entityDescriptor, implementors);
}

public EntityStructInitializer BuildEntity<T>(int entityID, ExclusiveGroup groupID, T descriptorEntity, object[] implementors) where T:IEntityDescriptor


+ 7
- 6
Svelto.ECS/EnginesRoot.Submission.cs View File

@@ -18,10 +18,8 @@ namespace Svelto.ECS
var entitiesOperations = _entitiesOperations.ToArrayFast();
for (int i = 0; i < _entitiesOperations.Count; i++)
{
#if DEBUG
try
{
#endif
switch (entitiesOperations[i].type)
{
case EntitySubmitOperationType.Swap:
@@ -36,13 +34,15 @@ namespace Svelto.ECS
RemoveGroupAndEntitiesFromDB(entitiesOperations[i].fromGroupID);
break;
}
#if DEBUG
}
catch (ECSException e)
{
Utility.Console.LogError(e.Message.FastConcat(" ", entitiesOperations[i].trace));
}
Svelto.Utilities.Console.LogError(e.Message.FastConcat(" ", entitiesOperations[i].trace));
#if DEBUG
throw;
#endif
}
}
_entitiesOperations.FastClear();
@@ -128,7 +128,8 @@ namespace Svelto.ECS
readonly FasterDictionary<int, Dictionary<Type, ITypeSafeDictionary>> _groupEntityDB;
//for each entity view type, return the groups (dictionary of entities indexed by entity id) where they are found indexed by group id
readonly Dictionary<Type, FasterDictionary<int, ITypeSafeDictionary>> _groupedGroups; //yes I am being sarcastic
readonly DoubleBufferedEntitiesToAdd<FasterDictionary<int, Dictionary<Type, ITypeSafeDictionary>>> _groupedEntityToAdd;
readonly DoubleBufferedEntitiesToAdd<FasterDictionary<int, Dictionary<Type, ITypeSafeDictionary>>>
_groupedEntityToAdd;
readonly EntitySubmissionScheduler _scheduler;
readonly FasterList<EntitySubmitOperation> _entitiesOperations;
}

+ 2
- 2
Svelto.ECS/EntityViewUtility.cs View File

@@ -53,7 +53,7 @@ static class EntityViewUtility
#if DEBUG && !PROFILER
else
{
Utility.Console.Log(NULL_IMPLEMENTOR_ERROR.FastConcat("Type ", entityDescriptorName, " entityView ",
Svelto.Utilities.Console.Log(NULL_IMPLEMENTOR_ERROR.FastConcat("Type ", entityDescriptorName, " entityView ",
entityBuilder.GetEntityType().ToString()));
}
#endif
@@ -80,7 +80,7 @@ static class EntityViewUtility
}
#if DEBUG && !PROFILER
if (component.numberOfImplementations > 1)
Utility.Console.LogError(DUPLICATE_IMPLEMENTOR_ERROR.FastConcat(
Svelto.Utilities.Console.LogError(DUPLICATE_IMPLEMENTOR_ERROR.FastConcat(
"Component Type: ", fieldType.Name,
" implementor: ",
component.implementorType.ToString()) +


+ 0
- 1
Svelto.ECS/IEntitiesDB.cs View File

@@ -57,7 +57,6 @@ namespace Svelto.ECS
void ExecuteOnEntities<T>(ExclusiveGroup groupID, EntitiesAction<T> action) where T : IEntityStruct;
void ExecuteOnEntities<T, W>(int groupID, ref W value, EntitiesAction<T, W> action) where T : IEntityStruct;
void ExecuteOnEntities<T, W>(ExclusiveGroup groupID, ref W value, EntitiesAction<T, W> action) where T : IEntityStruct;

/// <summary>
/// Execute an action on ALL the entities regardless the group. This function doesn't guarantee cache
/// friendliness even if just EntityStructs are used.


+ 1
- 1
Svelto.ECS/IEntityFactory.cs View File

@@ -49,6 +49,6 @@ namespace Svelto.ECS
/// <param name="implementors"></param>
///
EntityStructInitializer BuildEntity<T>(int entityID, ExclusiveGroup groupID, T descriptorEntity, object[] implementors) where T:IEntityDescriptor;
EntityStructInitializer BuildEntity<T>(EGID egid, T descriptorEntity, object[] implementors) where T:IEntityDescriptor;
EntityStructInitializer BuildEntity<T>(EGID egid, T entityDescriptor, object[] implementors) where T:IEntityDescriptor;
}
}

+ 2
- 2
Svelto.ECS/Sequencer.cs View File

@@ -10,7 +10,7 @@ namespace Svelto.ECS
{
if (ContainsKey(engine))
{
Utility.Console.LogError("can't hold multiple steps with the same engine as origin in a Sequencer");
Svelto.Utilities.Console.LogError("can't hold multiple steps with the same engine as origin in a Sequencer");
}
base.Add(engine, dictionary);
}
@@ -42,7 +42,7 @@ namespace Svelto.ECS
var steps = (_steps[engine] as Dictionary<C, IStep<C>[]>)[branch];

if (steps == null)
Utility.Console.LogError("selected steps not found in sequencer ".FastConcat(this.ToString()));
Svelto.Utilities.Console.LogError("selected steps not found in sequencer ".FastConcat(this.ToString()));
for (var i = 0; i < steps.Length; i++)
steps[i].Step(condition, id);


Loading…
Cancel
Save