From 3c0aa03643b53b03c3ac0df3e6909a4c8863abdc Mon Sep 17 00:00:00 2001 From: neuecc Date: Tue, 9 Jun 2020 14:52:04 +0900 Subject: [PATCH] if def --- README.md | 2 ++ .../Runtime/CompilerServices/StateMachineRunner.cs | 12 ++++++++++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index a78c89c..38b74ff 100644 --- a/README.md +++ b/README.md @@ -690,6 +690,8 @@ foreach (var (type, size) in TaskPool.GetCacheSizeInfo()) } ``` +> In UnityEditor profiler shows allocation of compiler generated AsyncStateMachine but it only occurs in debug(development) build. C# Compiler generate AsyncStateMachine as class on Debug build and as struct on Release build. And also currently due to IL2CPP limitation, in IL2CPP build, UniTask do boxing AsyncStateMachine when needed so sometimes exists `one` allocation. + API References --- UniTask's API References is hosted at [cysharp.github.io/UniTask](https://cysharp.github.io/UniTask/api/Cysharp.Threading.Tasks.html) by [DocFX](https://dotnet.github.io/docfx/) and [Cysharp/DocfXTemplate](https://github.com/Cysharp/DocfxTemplate). diff --git a/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/StateMachineRunner.cs b/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/StateMachineRunner.cs index d452b6b..067c048 100644 --- a/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/StateMachineRunner.cs +++ b/src/UniTask/Assets/Plugins/UniTask/Runtime/CompilerServices/StateMachineRunner.cs @@ -45,7 +45,11 @@ namespace Cysharp.Threading.Tasks.CompilerServices { static TaskPool> pool; +#if ENABLE_IL2CPP IAsyncStateMachine stateMachine; // unfortunatelly boxed to fix IL2CPP issue. +#else + TStateMachine stateMachine; +#endif public Action MoveNext { get; } @@ -113,7 +117,11 @@ namespace Cysharp.Threading.Tasks.CompilerServices { static TaskPool> pool; +#if ENABLE_IL2CPP IAsyncStateMachine stateMachine; // unfortunatelly boxed to fix IL2CPP issue. +#else + TStateMachine stateMachine; +#endif public Action MoveNext { get; } @@ -224,7 +232,11 @@ namespace Cysharp.Threading.Tasks.CompilerServices { static TaskPool> pool; +#if ENABLE_IL2CPP IAsyncStateMachine stateMachine; // unfortunatelly boxed to fix IL2CPP issue. +#else + TStateMachine stateMachine; +#endif public Action MoveNext { get; }