public unsafe static void Initialize() { #if !UNITY_SINGLETHREADED_JOBS // We need to push the thread count before the jobs run, because we can't make a lazy // call to Environment.ProcessorCount from Burst. // about the 8 thread restriction: https://unity3d.atlassian.net/browse/DOTSR-1499 s_JobWorkerCount.Data = Environment.ProcessorCount < 8 ? Environment.ProcessorCount : 8; s_JobQueue.Data = CreateJobQueue((IntPtr)UnsafeUtility.AddressOf(ref JobQueueName[0]), (IntPtr)UnsafeUtility.AddressOf(ref WorkerThreadName[0]), JobWorkerCount); s_BatchScheduler.Data = CreateJobBatchScheduler(); #if ENABLE_UNITY_COLLECTIONS_CHECKS AtomicSafetyHandle.AtomicSafetyHandle_SetBatchScheduler((void *)s_BatchScheduler.Data); #endif #endif }
public static unsafe void Shutdown() { #if !UNITY_SINGLETHREADED_JOBS if (s_BatchScheduler.Data != IntPtr.Zero) { #if ENABLE_UNITY_COLLECTIONS_CHECKS AtomicSafetyHandle.AtomicSafetyHandle_SetBatchScheduler(null); #endif DestroyJobBatchScheduler(s_BatchScheduler.Data); s_BatchScheduler.Data = IntPtr.Zero; } if (s_JobQueue.Data != IntPtr.Zero) { DestroyJobQueue(); s_JobQueue.Data = IntPtr.Zero; } #endif }