用于并行流程继续点。
所有并行流程实例都是等效的,并且连接到之前发生的同一 Begin 或 Next 事件。流程起点的一个示例是作业计划。例如,IJobParallelForExtensions.Schedule 会生成一个隐式 Begin Profiler 流程事件和 IJobParallelFor.Execute 会生成一个隐式 ParallelNext 事件。
using System; using System.Threading; using Unity.Profiling; using Unity.Profiling.LowLevel; using Unity.Profiling.LowLevel.Unsafe;
public class Example { static readonly ProfilerMarker k_ScheduleParallelTasksMarker = new ProfilerMarker("Schedule Parallel Tasks"); static readonly ProfilerMarker k_ParallelTaskMarker = new ProfilerMarker("Parallel Task");
static void EmitFlowEventAndChainThread(uint flowId) { // Mark the next k_ParallelTaskMarker as a beginning of the flow ProfilerUnsafeUtility.FlowEvent(flowId, ProfilerFlowEventType.ParallelNext); using (k_ParallelTaskMarker.Auto()) { // Do work } }
static void ScheduleParallelTask() { using (k_ScheduleParallelTasksMarker.Auto()) { var flowId = ProfilerUnsafeUtility.CreateFlow(ProfilerUnsafeUtility.CategoryScripts); // Mark the parent k_ScheduleParallelTasksMarker as a beginning of the flow ProfilerUnsafeUtility.FlowEvent(flowId, ProfilerFlowEventType.Begin); var thread = new Thread(() => EmitFlowEventAndChainThread(flowId)); thread.Start(); } } }