mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
fix thread safety for ecsdebug
This commit is contained in:
parent
7cf6894476
commit
f2ffc284f9
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user