com.wallstop-studios.unity-helpers 1.0.1-rc10 → 1.0.1-rc12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,18 +6,22 @@
6
6
 
7
7
  public sealed class SingleThreadedThreadPool : IDisposable
8
8
  {
9
+ public ConcurrentQueue<Exception> Exceptions => _exceptions;
10
+
9
11
  private int _active;
10
12
  private int _working;
11
13
  private Thread _worker;
12
14
  private readonly ConcurrentQueue<Action> _work;
13
15
  private AutoResetEvent _waitHandle;
14
16
  private bool _disposed;
17
+ private readonly ConcurrentQueue<Exception> _exceptions;
15
18
 
16
19
  public SingleThreadedThreadPool()
17
20
  {
18
21
  _active = 1;
19
22
  _working = 1;
20
23
  _work = new ConcurrentQueue<Action>();
24
+ _exceptions = new ConcurrentQueue<Exception>();
21
25
  _waitHandle = new AutoResetEvent(false);
22
26
  _worker = new Thread(DoWork);
23
27
  _worker.Start();
@@ -40,15 +44,16 @@
40
44
  {
41
45
  workItem();
42
46
  }
43
- catch
47
+ catch (Exception e)
44
48
  {
45
- // Ignore (TODO: Log to some output function? The downside here is that this is in another thread, which means standard Unity logging is a no-go)
49
+ _exceptions.Enqueue(e);
46
50
  }
47
51
  }
48
52
  else
49
53
  {
50
54
  _ = _waitHandle.WaitOne(TimeSpan.FromSeconds(1));
51
55
  }
56
+
52
57
  _ = Interlocked.Exchange(ref _working, 0);
53
58
  }
54
59
  }
@@ -92,6 +97,7 @@
92
97
  {
93
98
  // Swallow
94
99
  }
100
+
95
101
  _waitHandle = null;
96
102
  _worker = null;
97
103
  }
@@ -99,4 +105,4 @@
99
105
  _disposed = true;
100
106
  }
101
107
  }
102
- }
108
+ }
@@ -1,11 +1,12 @@
1
1
  namespace UnityHelpers.Utils
2
2
  {
3
+ using System;
3
4
  using UnityEngine;
4
5
 
5
6
  [DisallowMultipleComponent]
6
7
  public abstract class RuntimeSingleton<T> : MonoBehaviour where T : RuntimeSingleton<T>
7
8
  {
8
- private static T _instance;
9
+ protected static T _instance;
9
10
 
10
11
  protected virtual bool Preserve => true;
11
12
 
@@ -18,7 +19,8 @@
18
19
  return _instance;
19
20
  }
20
21
 
21
- GameObject instance = new(typeof(T).Name + "Singleton", typeof(T));
22
+ Type type = typeof(T);
23
+ GameObject instance = new($"{type.Name}-Singleton", type);
22
24
  if (instance.TryGetComponent(out _instance) && _instance.Preserve)
23
25
  {
24
26
  DontDestroyOnLoad(instance);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "com.wallstop-studios.unity-helpers",
3
- "version": "1.0.1-rc10",
3
+ "version": "1.0.1-rc12",
4
4
  "displayName": "Unity Helpers",
5
5
  "description": "Various Unity Helper Library",
6
6
  "dependencies": {