Guest User

Jobs #2

a guest
May 22nd, 2023
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 KB | None | 0 0
  1.  
  2.     public static unsafe class IJobSingleExtensions {
  3.        
  4.         public static JobHandle Schedule<T>(this T jobData, JobHandle inputDeps = default) where T : struct, IJobSingle {
  5.            
  6.             var parameters = new JobsUtility.JobScheduleParameters(UnsafeUtility.AddressOf(ref jobData), JobProcess<T>.Initialize(), inputDeps, ScheduleMode.Single);
  7.             return JobsUtility.Schedule(ref parameters);
  8.            
  9.         }
  10.  
  11.         internal struct JobProcess<T> where T : struct, IJobSingle {
  12.            
  13.             private static System.IntPtr jobReflectionData;
  14.  
  15.             public static System.IntPtr Initialize() {
  16.                 if (jobReflectionData == System.IntPtr.Zero) {
  17.                     jobReflectionData = JobsUtility.CreateJobReflectionData(typeof(T), typeof(T), (ExecuteJobFunction)Execute);
  18.                 }
  19.                 return jobReflectionData;
  20.             }
  21.  
  22.             public delegate void ExecuteJobFunction(ref T jobData, System.IntPtr additionalData, System.IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex);
  23.  
  24.             public static void Execute(ref T jobData, System.IntPtr additionalData, System.IntPtr bufferRangePatchData, ref JobRanges ranges, int jobIndex) {
  25.  
  26.             }
  27.         }
  28.     }
Advertisement
Add Comment
Please, Sign In to add comment