using System;
using System.Collections.Generic;
using UnityEngine;
namespace Unity.Jobs
{
///
/// Used by automatically generated code. Do not use in projects.
///
public class EarlyInitHelpers
{
///
/// Used by automatically generated code. Do not use in projects.
/// Delegate used for early initialization
///
public delegate void EarlyInitFunction();
private static List s_PendingDelegates;
static EarlyInitHelpers()
{
FlushEarlyInits();
}
///
/// Used by automatically generated code. Do not use in projects.
/// Calls all EarlyInit delegates and clears the invocation list
///
public static void FlushEarlyInits()
{
while (s_PendingDelegates != null)
{
var oldList = s_PendingDelegates;
s_PendingDelegates = null;
for (int i = 0; i < oldList.Count; ++i)
{
try
{
oldList[i]();
}
catch (Exception ex)
{
Debug.LogException(ex);
}
}
}
}
///
/// Used by automatically generated code. Do not use in projects.
/// Adds an EarlyInit helper function to invocation list.
///
/// EarlyInitFunction add to early call list
public static void AddEarlyInitFunction(EarlyInitFunction func)
{
if (s_PendingDelegates == null)
s_PendingDelegates = new List();
s_PendingDelegates.Add(func);
}
///
/// Used by automatically generated code. Do not use in projects.
/// This methods is called when JobReflectionData cannot be created during EarlyInit.
///
/// Exception type to throw
public static void JobReflectionDataCreationFailed(Exception ex)
{
Debug.LogError($"Failed to create job reflection data. Please refer to callstack of exception for information on which job could not produce its reflection data.");
Debug.LogException(ex);
}
}
}