Force complete awaiting JobHandles when quitted in UnityEditor
parent
e82353b4d9
commit
fd70c031cb
|
@ -101,7 +101,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
static SynchronizationContext unitySynchronizationContetext;
|
static SynchronizationContext unitySynchronizationContetext;
|
||||||
static ContinuationQueue[] yielders;
|
static ContinuationQueue[] yielders;
|
||||||
static PlayerLoopRunner[] runners;
|
static PlayerLoopRunner[] runners;
|
||||||
|
internal static bool IsEditorApplicationQuitting { get; private set; }
|
||||||
static PlayerLoopSystem[] InsertRunner(PlayerLoopSystem loopSystem,
|
static PlayerLoopSystem[] InsertRunner(PlayerLoopSystem loopSystem,
|
||||||
Type loopRunnerYieldType, ContinuationQueue cq, Type lastLoopRunnerYieldType, ContinuationQueue lastCq,
|
Type loopRunnerYieldType, ContinuationQueue cq, Type lastLoopRunnerYieldType, ContinuationQueue lastCq,
|
||||||
Type loopRunnerType, PlayerLoopRunner runner, Type lastLoopRunnerType, PlayerLoopRunner lastRunner)
|
Type loopRunnerType, PlayerLoopRunner runner, Type lastLoopRunnerType, PlayerLoopRunner lastRunner)
|
||||||
|
@ -112,6 +112,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
{
|
{
|
||||||
if (state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.ExitingEditMode)
|
if (state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.ExitingEditMode)
|
||||||
{
|
{
|
||||||
|
IsEditorApplicationQuitting = true;
|
||||||
// run rest action before clear.
|
// run rest action before clear.
|
||||||
if (runner != null)
|
if (runner != null)
|
||||||
{
|
{
|
||||||
|
@ -134,6 +135,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
lastCq.Run();
|
lastCq.Run();
|
||||||
lastCq.Clear();
|
lastCq.Clear();
|
||||||
}
|
}
|
||||||
|
IsEditorApplicationQuitting = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using Unity.Jobs;
|
using Unity.Jobs;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace Cysharp.Threading.Tasks
|
namespace Cysharp.Threading.Tasks
|
||||||
{
|
{
|
||||||
|
@ -85,7 +86,7 @@ namespace Cysharp.Threading.Tasks
|
||||||
|
|
||||||
public bool MoveNext()
|
public bool MoveNext()
|
||||||
{
|
{
|
||||||
if (jobHandle.IsCompleted)
|
if (jobHandle.IsCompleted | PlayerLoopHelper.IsEditorApplicationQuitting)
|
||||||
{
|
{
|
||||||
jobHandle.Complete();
|
jobHandle.Complete();
|
||||||
core.TrySetResult(AsyncUnit.Default);
|
core.TrySetResult(AsyncUnit.Default);
|
||||||
|
|
Loading…
Reference in New Issue