com.wallstop-studios.unity-helpers 1.0.1-rc11 → 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
|
-
|
|
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
|
+
}
|