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
thrownewInvalidOperationException("Tried to set a parent on a job that is already eligible for execution. This is not allowed as it can lead to deadlocks or unexpected behavior.");
246
+
}
225
247
if(parent.IsNull)
226
248
{
227
-
return;
249
+
thrownewArgumentNullException(nameof(parent),"Cannot set a null parent on a job handle.");
228
250
}
251
+
229
252
Interlocked.Increment(refparent.UnfinishedJobs);
230
253
Parent=parent.Index;
231
254
}
@@ -273,6 +296,10 @@ public bool IsHandleAlreadyRecycled()
273
296
/// <param name="source">The handle that triggers the current handle</param>
274
297
publicvoidSetDependsOn(JobHandlesource)
275
298
{
299
+
if(IsJobEligibleForExecution())
300
+
{
301
+
thrownewInvalidOperationException("Tried to set a dependency on a job that is already eligible for execution. This is not allowed as it can lead to deadlocks or unexpected behavior.");
302
+
}
276
303
source.AddDependent(this);
277
304
}
278
305
@@ -315,6 +342,10 @@ public void FlushAndWait()
315
342
/// <param name="target">What to be added to be executed after</param>
316
343
privatevoidAddDependent(JobHandletarget)
317
344
{
345
+
if(IsJobEligibleForExecution())
346
+
{
347
+
thrownew("Tried to add a dependent to a job that is already eligible for execution. This is not allowed as it can lead to deadlocks or unexpected behavior.");
// We use Environment.ProcessorCount * 4 to account for uneven distribution of work and to ensure that we have enough partitions to keep all cores busy.
34
34
// The overhead of jobs is very low hence we can afford to have more partitions than cores.
0 commit comments