changed clear loop runner queue timing in UnityEditor and run rest action when quitted
parent
5d4a90e9bd
commit
3f18b37e5f
|
@ -70,13 +70,17 @@ namespace Cysharp.Threading.Tasks.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
public int Clear()
|
||||
{
|
||||
var rest = actionListCount + waitingListCount;
|
||||
|
||||
actionListCount = 0;
|
||||
actionList = new Action[InitialSize];
|
||||
|
||||
waitingListCount = 0;
|
||||
waitingList = new Action[InitialSize];
|
||||
|
||||
return rest;
|
||||
}
|
||||
|
||||
// delegate entrypoint.
|
||||
|
|
|
@ -48,14 +48,24 @@ namespace Cysharp.Threading.Tasks.Internal
|
|||
}
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
public int Clear()
|
||||
{
|
||||
lock (arrayLock)
|
||||
{
|
||||
var rest = 0;
|
||||
|
||||
for (var index = 0; index < loopItems.Length; index++)
|
||||
{
|
||||
if (loopItems[index] != null)
|
||||
{
|
||||
rest++;
|
||||
}
|
||||
|
||||
loopItems[index] = null;
|
||||
}
|
||||
|
||||
tail = 0;
|
||||
return rest;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -110,28 +110,31 @@ namespace Cysharp.Threading.Tasks
|
|||
#if UNITY_EDITOR
|
||||
EditorApplication.playModeStateChanged += (state) =>
|
||||
{
|
||||
if (state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.EnteredPlayMode)
|
||||
if (state == PlayModeStateChange.EnteredEditMode || state == PlayModeStateChange.ExitingEditMode)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// run rest action before clear.
|
||||
if (runner != null)
|
||||
{
|
||||
runner.Run();
|
||||
runner.Clear();
|
||||
}
|
||||
if (lastRunner != null)
|
||||
{
|
||||
lastRunner.Run();
|
||||
lastRunner.Clear();
|
||||
}
|
||||
|
||||
if (cq != null)
|
||||
{
|
||||
cq.Run();
|
||||
cq.Clear();
|
||||
}
|
||||
if (lastCq != null)
|
||||
{
|
||||
lastCq.Run();
|
||||
lastCq.Clear();
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
|
|
|
@ -492,8 +492,33 @@ public class SandboxMain : MonoBehaviour
|
|||
Debug.Log("Current SyncContext:" + SynchronizationContext.Current.GetType().FullName);
|
||||
}
|
||||
|
||||
|
||||
async UniTask QuitCheck()
|
||||
{
|
||||
try
|
||||
{
|
||||
await UniTask.Delay(TimeSpan.FromMinutes(1), cancellationToken: quitSource.Token);
|
||||
}
|
||||
finally
|
||||
{
|
||||
Debug.Log("End QuitCheck async");
|
||||
}
|
||||
}
|
||||
|
||||
CancellationTokenSource quitSource = new CancellationTokenSource();
|
||||
|
||||
async UniTaskVoid Start()
|
||||
{
|
||||
Debug.Log("App Start");
|
||||
|
||||
Application.quitting += () =>
|
||||
{
|
||||
Debug.Log("called quitting");
|
||||
quitSource.Cancel();
|
||||
};
|
||||
|
||||
QuitCheck().Forget();
|
||||
|
||||
//Expression.Lambda<Func<int>>(null).Compile(true);
|
||||
|
||||
//RunStandardTaskAsync();
|
||||
|
|
Loading…
Reference in New Issue