mirror of
https://github.com/DCFApixels/DragonECS-ClassicThreads.git
synced 2025-09-17 19:24:37 +08:00
update
This commit is contained in:
parent
4801a7a40b
commit
9782fa9cb7
@ -9,13 +9,14 @@ namespace DCFApixels.DragonECS
|
|||||||
private static ThreadReacord[] _threads;
|
private static ThreadReacord[] _threads;
|
||||||
|
|
||||||
private static ThreadWorkerHandler _worker;
|
private static ThreadWorkerHandler _worker;
|
||||||
|
private static ThreadWorkerHandler _nullWorker = delegate { };
|
||||||
private static int[] _entities = new int[64];
|
private static int[] _entities = new int[64];
|
||||||
|
|
||||||
private static void ThreadProc(object obj)
|
private static void ThreadProc(object obj)
|
||||||
{
|
{
|
||||||
ref ThreadReacord record = ref _threads[(int)obj];
|
ref ThreadReacord record = ref _threads[(int)obj];
|
||||||
try
|
//try
|
||||||
{
|
//{
|
||||||
while (Thread.CurrentThread.IsAlive)
|
while (Thread.CurrentThread.IsAlive)
|
||||||
{
|
{
|
||||||
record.runWork.WaitOne();
|
record.runWork.WaitOne();
|
||||||
@ -23,8 +24,8 @@ namespace DCFApixels.DragonECS
|
|||||||
_worker.Invoke(new ReadOnlySpan<int>(_entities, record.start, record.size));
|
_worker.Invoke(new ReadOnlySpan<int>(_entities, record.start, record.size));
|
||||||
record.doneWork.Set();
|
record.doneWork.Set();
|
||||||
}
|
}
|
||||||
}
|
//}
|
||||||
catch { }
|
//catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
static ThreadRunner()
|
static ThreadRunner()
|
||||||
@ -42,7 +43,7 @@ namespace DCFApixels.DragonECS
|
|||||||
};
|
};
|
||||||
_threads[i].thread.Start(i);
|
_threads[i].thread.Start(i);
|
||||||
}
|
}
|
||||||
_worker = delegate { };
|
_worker = _nullWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Run(ThreadWorkerHandler worker, EcsReadonlyGroup entities, int minSpanSize)
|
public static void Run(ThreadWorkerHandler worker, EcsReadonlyGroup entities, int minSpanSize)
|
||||||
@ -86,7 +87,7 @@ namespace DCFApixels.DragonECS
|
|||||||
_threads[i].doneWork.WaitOne();
|
_threads[i].doneWork.WaitOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
_worker = null;
|
_worker = _nullWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
private struct ThreadReacord
|
private struct ThreadReacord
|
||||||
|
Loading…
Reference in New Issue
Block a user