File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
UnityAsync/Assets/UnityAsync/Manager Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -57,6 +57,16 @@ public void Process()
57
57
58
58
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
59
59
public void Add ( in T cont )
60
+ {
61
+ if ( InUnityContext )
62
+ AddFast ( cont ) ;
63
+ else
64
+ AddThreadSafe ( cont ) ;
65
+ }
66
+
67
+ // only call in UnitySynchronizationContext - not thread safe
68
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
69
+ void AddFast ( in T cont )
60
70
{
61
71
try
62
72
{
@@ -86,6 +96,15 @@ public void Add(in T cont)
86
96
}
87
97
}
88
98
99
+ // use when you may be adding an awaiter from outside of UnitySynchronizationContext
100
+ [ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
101
+ async void AddThreadSafe ( T cont )
102
+ {
103
+ await UnitySyncContext ;
104
+
105
+ AddFast ( cont ) ;
106
+ }
107
+
89
108
[ MethodImpl ( MethodImplOptions . AggressiveInlining ) ]
90
109
static void AssertQueueSize ( int queueSize )
91
110
{
You can’t perform that action at this time.
0 commit comments