fix thread safety for ecsdebug

This commit is contained in:
Mikhail 2024-09-10 19:18:46 +08:00
parent 7cf6894476
commit f2ffc284f9

View File

@ -123,22 +123,31 @@ namespace DCFApixels.DragonECS
get
{
if (_instance == null)
{
lock (_lock)
{
_instance = new DefaultDebugService();
}
}
return _instance;
}
}
public static void Set<T>() where T : DebugService, new()
{
lock (_lock)
{
Set(new T());
}
}
public static void Set(DebugService service)
{
lock (_lock)
{
_instance = service;
OnServiceChanged(_instance);
}
}
public static Action<DebugService> OnServiceChanged = delegate { };
@ -161,13 +170,16 @@ namespace DCFApixels.DragonECS
return id;
}
public void DeleteMark(string name)
{
lock (_lock)
{
int id = _nameIdTable[name];
//TODO кажется этот TryRemove не подходит
//TODO проверить TryRemove
_nameIdTable.TryRemove(name, out id);
_idDispenser.Release(id);
OnDelProfilerMark(id);
}
}
protected abstract void OnNewProfilerMark(int id, string name);
protected abstract void OnDelProfilerMark(int id);