diff --git a/src/UniTask.NetCore/NetCore/UniTask.Yield.cs b/src/UniTask.NetCore/NetCore/UniTask.Yield.cs index 77768a0..4a39153 100644 --- a/src/UniTask.NetCore/NetCore/UniTask.Yield.cs +++ b/src/UniTask.NetCore/NetCore/UniTask.Yield.cs @@ -66,7 +66,7 @@ namespace Cysharp.Threading.Tasks static ThreadPoolWorkItem() { - TaskPoolMonitor.RegisterSizeGetter(typeof(ThreadPoolWorkItem), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(ThreadPoolWorkItem), () => pool.Size); } Action continuation; diff --git a/src/UniTask.NetCoreSandbox/Program.cs b/src/UniTask.NetCoreSandbox/Program.cs index ccc0966..706e6e0 100644 --- a/src/UniTask.NetCoreSandbox/Program.cs +++ b/src/UniTask.NetCoreSandbox/Program.cs @@ -236,7 +236,7 @@ namespace NetCoreSandbox //await c; - foreach (var item in Cysharp.Threading.Tasks.Internal.TaskPoolMonitor.GetCacheSizeInfo()) + foreach (var item in Cysharp.Threading.Tasks.Internal.TaskPool.GetCacheSizeInfo()) { Console.WriteLine(item); } diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs index 78e4a51..e33febd 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/MoveNextRunner.cs @@ -57,7 +57,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices static AsyncUniTaskVoid() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AsyncUniTaskVoid), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AsyncUniTaskVoid), () => pool.Size); } public AsyncUniTaskVoid NextNode { get; set; } @@ -129,7 +129,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices static AsyncUniTask() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AsyncUniTask), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AsyncUniTask), () => pool.Size); } bool TryReturn() @@ -240,7 +240,7 @@ namespace Cysharp.Threading.Tasks.CompilerServices static AsyncUniTask() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AsyncUniTask), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AsyncUniTask), () => pool.Size); } bool TryReturn() diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/EnumeratorAsyncExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/EnumeratorAsyncExtensions.cs index e312519..7c658dd 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/EnumeratorAsyncExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/EnumeratorAsyncExtensions.cs @@ -37,7 +37,7 @@ namespace Cysharp.Threading.Tasks static EnumeratorPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(EnumeratorPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(EnumeratorPromise), () => pool.Size); } IEnumerator innerEnumerator; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/AddressableAsyncExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/AddressableAsyncExtensions.cs index acfc101..8edda50 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/AddressableAsyncExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/AddressableAsyncExtensions.cs @@ -84,7 +84,7 @@ namespace Cysharp.Threading.Tasks static AsyncOperationHandleConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AsyncOperationHandleConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AsyncOperationHandleConfiguredSource), () => pool.Size); } AsyncOperationHandle handle; @@ -272,7 +272,7 @@ namespace Cysharp.Threading.Tasks static AsyncOperationHandleConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AsyncOperationHandleConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AsyncOperationHandleConfiguredSource), () => pool.Size); } AsyncOperationHandle handle; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs index 8813878..1858776 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/External/DoTweenAsyncExtensions.cs @@ -90,7 +90,7 @@ namespace Cysharp.Threading.Tasks static TweenConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(TweenConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(TweenConfiguredSource), () => pool.Size); } static readonly Action CancellationCallbackDelegate = CancellationCallback; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PooledDelegate.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PooledDelegate.cs index 56d08f5..8d76d98 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PooledDelegate.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PooledDelegate.cs @@ -11,7 +11,7 @@ namespace Cysharp.Threading.Tasks.Internal static PooledDelegate() { - TaskPoolMonitor.RegisterSizeGetter(typeof(PooledDelegate), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(PooledDelegate), () => pool.Size); } readonly Action runDelegate; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PromisePool.cs.meta b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PromisePool.cs.meta deleted file mode 100644 index 76cc60b..0000000 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/PromisePool.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: fcb1f7467a3e2b64c8a016c8aee2f9b4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/TaskPool.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/TaskPool.cs index f3be551..8860854 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/TaskPool.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/Internal/TaskPool.cs @@ -12,6 +12,7 @@ namespace Cysharp.Threading.Tasks.Internal public static class TaskPool { internal static int MaxPoolSize; + static ConcurrentDictionary> sizes = new ConcurrentDictionary>(); static TaskPool() { @@ -36,6 +37,19 @@ namespace Cysharp.Threading.Tasks.Internal { MaxPoolSize = maxPoolSize; } + + public static IEnumerable<(Type, int)> GetCacheSizeInfo() + { + foreach (var item in sizes) + { + yield return (item.Key, item.Value()); + } + } + + public static void RegisterSizeGetter(Type type, Func getSize) + { + sizes[type] = getSize; + } } @@ -98,22 +112,4 @@ namespace Cysharp.Threading.Tasks.Internal return false; } } - - public static class TaskPoolMonitor - { - static ConcurrentDictionary> sizes = new ConcurrentDictionary>(); - - public static IEnumerable<(Type, int)> GetCacheSizeInfo() - { - foreach (var item in sizes) - { - yield return (item.Key, item.Value()); - } - } - - public static void RegisterSizeGetter(Type type, Func getSize) - { - sizes[type] = getSize; - } - } } \ No newline at end of file diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs index 65b02fc..cf4b6d4 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.Delay.cs @@ -63,7 +63,7 @@ namespace Cysharp.Threading.Tasks static YieldPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(YieldPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(YieldPromise), () => pool.Size); } CancellationToken cancellationToken; @@ -159,7 +159,7 @@ namespace Cysharp.Threading.Tasks static DelayFramePromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(DelayFramePromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(DelayFramePromise), () => pool.Size); } int delayFrameCount; @@ -266,7 +266,7 @@ namespace Cysharp.Threading.Tasks static DelayPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(DelayPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(DelayPromise), () => pool.Size); } float delayFrameTimeSpan; @@ -374,7 +374,7 @@ namespace Cysharp.Threading.Tasks static DelayIgnoreTimeScalePromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(DelayIgnoreTimeScalePromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(DelayIgnoreTimeScalePromise), () => pool.Size); } float delayFrameTimeSpan; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs index ce58448..c427816 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTask.WaitUntil.cs @@ -42,7 +42,7 @@ namespace Cysharp.Threading.Tasks static WaitUntilPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(WaitUntilPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(WaitUntilPromise), () => pool.Size); } Func predicate; @@ -154,7 +154,7 @@ namespace Cysharp.Threading.Tasks static WaitWhilePromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(WaitWhilePromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(WaitWhilePromise), () => pool.Size); } Func predicate; @@ -266,7 +266,7 @@ namespace Cysharp.Threading.Tasks static WaitUntilCanceledPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(WaitUntilCanceledPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(WaitUntilCanceledPromise), () => pool.Size); } CancellationToken cancellationToken; @@ -362,7 +362,7 @@ namespace Cysharp.Threading.Tasks static WaitUntilValueChangedUnityObjectPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(WaitUntilValueChangedUnityObjectPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(WaitUntilValueChangedUnityObjectPromise), () => pool.Size); } T target; @@ -493,7 +493,7 @@ namespace Cysharp.Threading.Tasks static WaitUntilValueChangedStandardObjectPromise() { - TaskPoolMonitor.RegisterSizeGetter(typeof(WaitUntilValueChangedStandardObjectPromise), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(WaitUntilValueChangedStandardObjectPromise), () => pool.Size); } WeakReference target; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs index 93974b0..638e50b 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UniTaskCompletionSource.cs @@ -382,7 +382,7 @@ namespace Cysharp.Threading.Tasks static AutoResetUniTaskCompletionSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AutoResetUniTaskCompletionSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AutoResetUniTaskCompletionSource), () => pool.Size); } UniTaskCompletionSourceCore core; @@ -608,7 +608,7 @@ namespace Cysharp.Threading.Tasks static AutoResetUniTaskCompletionSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AutoResetUniTaskCompletionSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AutoResetUniTaskCompletionSource), () => pool.Size); } UniTaskCompletionSourceCore core; diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs index 05efb7c..23048fc 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/UnityAsyncExtensions.cs @@ -82,7 +82,7 @@ namespace Cysharp.Threading.Tasks static AsyncOperationConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AsyncOperationConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AsyncOperationConfiguredSource), () => pool.Size); } AsyncOperation asyncOperation; @@ -264,7 +264,7 @@ namespace Cysharp.Threading.Tasks static ResourceRequestConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(ResourceRequestConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(ResourceRequestConfiguredSource), () => pool.Size); } ResourceRequest asyncOperation; @@ -451,7 +451,7 @@ namespace Cysharp.Threading.Tasks static AssetBundleRequestConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AssetBundleRequestConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AssetBundleRequestConfiguredSource), () => pool.Size); } AssetBundleRequest asyncOperation; @@ -637,7 +637,7 @@ namespace Cysharp.Threading.Tasks static AssetBundleCreateRequestConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(AssetBundleCreateRequestConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(AssetBundleCreateRequestConfiguredSource), () => pool.Size); } AssetBundleCreateRequest asyncOperation; @@ -824,7 +824,7 @@ namespace Cysharp.Threading.Tasks static UnityWebRequestAsyncOperationConfiguredSource() { - TaskPoolMonitor.RegisterSizeGetter(typeof(UnityWebRequestAsyncOperationConfiguredSource), () => pool.Size); + TaskPool.RegisterSizeGetter(typeof(UnityWebRequestAsyncOperationConfiguredSource), () => pool.Size); } UnityWebRequestAsyncOperation asyncOperation;