You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
UnfinishedJobs=2,// 2 unfinished, because 1 is the job itself, and 1 is whether the job can be scheduled at all yet
104
103
Dependents=null,
105
104
};
@@ -116,7 +115,7 @@ public void ReturnHandle(JobHandle handle)
116
115
{
117
116
for(vari=0;i<handle.Dependents!.Length;i++)
118
117
{
119
-
handle.Dependents[i]=JobHandle.NullHandle;
118
+
handle.Dependents[i]=JobHandle.NullHandleId;
120
119
}
121
120
}
122
121
@@ -139,20 +138,48 @@ public struct JobHandle
139
138
/// <summary>
140
139
/// Invalid handle value, used to indicate that a <see cref="JobHandle"/> is not valid.
141
140
/// </summary>
142
-
publicconstushortNullHandle=ushort.MaxValue;
141
+
publicconstushortNullHandleId=ushort.MaxValue;
143
142
144
143
/// <summary>
145
144
/// The index of this <see cref="JobHandle"/>, pointing towards its data inside the <see cref="Pool"/>.
146
145
/// </summary>
147
146
publicushortIndex;
148
147
148
+
/// <summary>
149
+
/// The generation of the handle.
150
+
/// It is only used to check whether the handle is still valid or has been recycled.
151
+
/// Which is only important when waiting for the handle.
152
+
/// Internally we can safely store handles without generation, as if there is a reference to it, it means it is still valid and has not been recycled yet.
153
+
/// Hence, in that case the generation is irrelevant as it is always the same as the current generation of the pool.
154
+
/// </summary>
155
+
internalushortGeneration;
156
+
157
+
privatereadonlybool_isInitialized;
158
+
/// <summary>
159
+
/// Indicates whether this <see cref="JobHandle"/> is null.
160
+
/// Default or Just JobHandle() is null, meaning it has not been initialized yet.
161
+
/// </summary>
162
+
publicreadonlyboolIsNull
163
+
{
164
+
get=>!_isInitialized;
165
+
}
166
+
149
167
/// <summary>
150
168
/// Creates a new <see cref="JobHandle"/>.
151
169
/// </summary>
152
170
/// <param name="id">Its id.</param>
153
171
publicJobHandle(ushortid)
154
172
{
155
173
Index=id;
174
+
_isInitialized=true;
175
+
}
176
+
177
+
/// <summary>
178
+
/// Gets a null handle.
179
+
/// </summary>
180
+
publicstaticJobHandleNull
181
+
{
182
+
get=>default;
156
183
}
157
184
158
185
/// <summary>
@@ -190,10 +217,15 @@ public ref int UnfinishedJobs
190
217
191
218
/// <summary>
192
219
/// Sets a <see cref="JobHandle"/> that is to be the parent.
220
+
/// If a null handle is passed it will be ignored.
thrownewInvalidOperationException("Dependents are not initialized. Please set them before using this method.");
311
362
}
312
363
313
-
returnDependents[^2]==NullHandle;
364
+
returnDependents[^2]==NullHandleId;
314
365
}
315
366
316
367
/// <summary>
@@ -325,21 +376,12 @@ private int GetFreeDependentsIndex()
325
376
326
377
for(vari=0;i<Dependents.Length;i++)
327
378
{
328
-
if(Dependents[i]==NullHandle)
379
+
if(Dependents[i]==NullHandleId)
329
380
{
330
381
returni;
331
382
}
332
383
}
333
384
334
385
return-1;
335
386
}
336
-
337
-
/// <summary>
338
-
/// The generation of the handle.
339
-
/// It is only used to check whether the handle is still valid or has been recycled.
340
-
/// Which is only important when waiting for the handle.
341
-
/// Internally we can safely store handles without generation, as if there is a reference to it, it means it is still valid and has not been recycled yet.
342
-
/// Hence, in that case the generation is irrelevant as it is always the same as the current generation of the pool.
0 commit comments