Mirror of Svelto.ECS because we're a fan of it
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

84 行
2.2KB

  1. #if UNITY_JOBS
  2. using System;
  3. using Unity.Jobs;
  4. namespace Svelto.ECS.SveltoOnDOTS
  5. {
  6. public struct DisposeJob<T>:IJob where T:struct,IDisposable
  7. {
  8. public DisposeJob(in T disposable)
  9. {
  10. _entityCollection = disposable;
  11. }
  12. public void Execute()
  13. {
  14. try
  15. {
  16. _entityCollection.Dispose();
  17. }
  18. catch (Exception e)
  19. {
  20. Console.LogException(e, this.GetType().ToString().FastConcat(" "));
  21. }
  22. }
  23. readonly T _entityCollection;
  24. }
  25. public struct DisposeJob<T1, T2>:IJob
  26. where T1:struct,IDisposable where T2:struct,IDisposable
  27. {
  28. public DisposeJob(in T1 disposable1, in T2 disposable2)
  29. {
  30. _entityCollection1 = disposable1;
  31. _entityCollection2 = disposable2;
  32. }
  33. public void Execute()
  34. {
  35. try
  36. {
  37. _entityCollection1.Dispose();
  38. _entityCollection2.Dispose();
  39. }
  40. catch (Exception e)
  41. {
  42. Console.LogException(e, this.GetType().ToString().FastConcat(" "));
  43. }
  44. }
  45. readonly T1 _entityCollection1;
  46. readonly T2 _entityCollection2;
  47. }
  48. public struct DisposeJob<T1, T2, T3>:IJob
  49. where T1:struct,IDisposable where T2:struct,IDisposable where T3:struct,IDisposable
  50. {
  51. public DisposeJob(in T1 disposable1, in T2 disposable2, in T3 disposable3)
  52. {
  53. _entityCollection1 = disposable1;
  54. _entityCollection2 = disposable2;
  55. _entityCollection3 = disposable3;
  56. }
  57. public void Execute()
  58. {
  59. try
  60. {
  61. _entityCollection1.Dispose();
  62. _entityCollection2.Dispose();
  63. _entityCollection3.Dispose();
  64. }
  65. catch (Exception e)
  66. {
  67. Console.LogException(e, this.GetType().ToString().FastConcat(" "));
  68. }
  69. }
  70. readonly T1 _entityCollection1;
  71. readonly T2 _entityCollection2;
  72. readonly T3 _entityCollection3;
  73. }
  74. }
  75. #endif