No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EarlyInitHelpers.cs 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. namespace Unity.Jobs
  5. {
  6. /// <summary>
  7. /// Used by automatically generated code. Do not use in projects.
  8. /// </summary>
  9. public class EarlyInitHelpers
  10. {
  11. /// <summary>
  12. /// Used by automatically generated code. Do not use in projects.
  13. /// Delegate used for early initialization
  14. /// </summary>
  15. public delegate void EarlyInitFunction();
  16. private static List<EarlyInitFunction> s_PendingDelegates;
  17. static EarlyInitHelpers()
  18. {
  19. FlushEarlyInits();
  20. }
  21. /// <summary>
  22. /// Used by automatically generated code. Do not use in projects.
  23. /// Calls all EarlyInit delegates and clears the invocation list
  24. /// </summary>
  25. public static void FlushEarlyInits()
  26. {
  27. while (s_PendingDelegates != null)
  28. {
  29. var oldList = s_PendingDelegates;
  30. s_PendingDelegates = null;
  31. for (int i = 0; i < oldList.Count; ++i)
  32. {
  33. try
  34. {
  35. oldList[i]();
  36. }
  37. catch (Exception ex)
  38. {
  39. Debug.LogException(ex);
  40. }
  41. }
  42. }
  43. }
  44. /// <summary>
  45. /// Used by automatically generated code. Do not use in projects.
  46. /// Adds an EarlyInit helper function to invocation list.
  47. /// </summary>
  48. /// <param name="func">EarlyInitFunction add to early call list</param>
  49. public static void AddEarlyInitFunction(EarlyInitFunction func)
  50. {
  51. if (s_PendingDelegates == null)
  52. s_PendingDelegates = new List<EarlyInitFunction>();
  53. s_PendingDelegates.Add(func);
  54. }
  55. /// <summary>
  56. /// Used by automatically generated code. Do not use in projects.
  57. /// This methods is called when JobReflectionData cannot be created during EarlyInit.
  58. /// </summary>
  59. /// <param name="ex">Exception type to throw</param>
  60. public static void JobReflectionDataCreationFailed(Exception ex)
  61. {
  62. 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.");
  63. Debug.LogException(ex);
  64. }
  65. }
  66. }