SlideShare a Scribd company logo
A Brief History of UniRx/UniTask, IUniTaskSource in Depth
河合 宜文 / Kawai Yoshifumi / @neuecc
Cysharp, Inc.
Cygames
C#大統一理論
C#
C#の可能性を切り開いていく
https://github.com/Cysharp
A Brief History of
UniRx/UniTask
https://twitter.com/neuecc/status/445836676791689216
A Brief History of UniRx/UniTask, IUniTaskSource in Depth
A Brief History of UniRx/UniTask, IUniTaskSource in Depth
IUniTaskSource in Depth
public readonly struct UniTask<T>
{
readonly T result;
readonly IUniTaskSource<T> source;
readonly short token;
}
public readonly struct UniTask<T>
{
readonly T result;
readonly IUniTaskSource<T> source;
readonly short token;
}
public readonly struct UniTask<T>
{
readonly T result;
readonly IUniTaskSource<T> source;
readonly short token;
}
public interface IUniTaskSource<out T>
{
T GetResult(short token);
UniTaskStatus GetStatus(short token);
void OnCompleted(Action<object> continuation, object state, short token);
}
internal sealed class AsyncUniTask<TStateMachine, T> :
IStateMachineRunnerPromise<T>, ITaskPoolNode<AsyncUniTask<TStateMachine, T>>,
IUniTaskSource<T> where TStateMachine : IAsyncStateMachine
{
public static void SetStateMachine(ref TStateMachine stateMachine, ref IStateMachineRunnerPro
{
// プールから取得する
if (!pool.TryPop(out var result))
{
result = new AsyncUniTask<TStateMachine, T>();
}
}
public T GetResult(short token)
{
try
{
return core.GetResult(token);
}
finally
{
core.Reset(); // core.version++
return pool.TryPush(this); // プールに返す}
}
}
internal sealed class AsyncUniTask<TStateMachine, T> :
IStateMachineRunnerPromise<T>, ITaskPoolNode<AsyncUniTask<TStateMachine, T>>,
IUniTaskSource<T> where TStateMachine : IAsyncStateMachine
{
public static void SetStateMachine(ref TStateMachine stateMachine, ref IStateMachineRunnerPro
{
// プールから取得する
if (!pool.TryPop(out var result))
{
result = new AsyncUniTask<TStateMachine, T>();
}
}
public T GetResult(short token)
{
try
{
return core.GetResult(token);
}
finally
{
core.Reset(); // core.version++
return pool.TryPush(this); // プールに返す}
}
}
public interface IUniTaskSource<out T>
{
T GetResult(short token);
UniTaskStatus GetStatus(short token);
void OnCompleted(Action<object> continuation, object state, short token);
}
public readonly struct UniTask<T>
{
readonly T result;
readonly IUniTaskSource<T> source;
readonly short token;
}
public interface IUniTaskSource<out T>
{
T GetResult(short token);
UniTaskStatus GetStatus(short token);
void OnCompleted(Action<object> continuation, object state, short token);
}
public readonly struct UniTask<T>
{
readonly T result;
readonly IUniTaskSource<T> source;
readonly short token;
}
public interface IUniTaskSource<out T>
{
T GetResult(short token);
UniTaskStatus GetStatus(short token);
void OnCompleted(Action<object> continuation, object state, short token);
}
public readonly struct UniTask<T>
{
readonly T result;
readonly IUniTaskSource<T> source;
readonly short token;
}
if (token != version)
{
throw new InvalidOperationException(
"Token version is not matched,
can not await twice or get Status after await.“
);
}
sealed class DelayPromise : IUniTaskSource,
IPlayerLoopItem, ITaskPoolNode<DelayPromise>
A Brief History of UniRx/UniTask, IUniTaskSource in Depth

More Related Content

What's hot (20)

PDF
Unityでオニオンアーキテクチャ
torisoup
 
PDF
ObserverパターンからはじめるUniRx
torisoup
 
PDF
MagicOnion~C#でゲームサーバを開発しよう~
torisoup
 
PDF
Observableで非同期処理
torisoup
 
PDF
Unity開発で使える設計の話+Zenjectの紹介
torisoup
 
PDF
Unityによるリアルタイム通信とMagicOnionによるC#大統一理論の実現
Yoshifumi Kawai
 
PPTX
世界一わかりやすいClean Architecture
Atsushi Nakamura
 
PPTX
【Unity道場Houdini編】Houdini Engine とプロシージャル法
UnityTechnologiesJapan002
 
PDF
Unityでオンラインゲーム作った話
torisoup
 
PDF
Unityでパフォーマンスの良いUIを作る為のTips
Unity Technologies Japan K.K.
 
PDF
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Yoshifumi Kawai
 
PDF
Nintendo Switch『OCTOPATH TRAVELER』はこうして作られた
エピック・ゲームズ・ジャパン Epic Games Japan
 
PDF
ライブラリ作成のすゝめ - 事例から見る個人OSS開発の効能
Yoshifumi Kawai
 
PDF
ソフトウェア開発における『知の高速道路』
Yoshitaka Kawashima
 
PDF
【Unite Tokyo 2019】運用中超大規模タイトルにおけるUnityアップデート課題の解決手法と事例
UnityTechnologiesJapan002
 
PDF
今日からできる!簡単 .NET 高速化 Tips
Takaaki Suzuki
 
PPTX
【Unity道場スペシャル 2017博多】クォータニオン完全マスター
Unity Technologies Japan K.K.
 
PDF
Reactive extensions入門v0.1
一希 大田
 
PPTX
大規模タイトルにおけるエフェクトマテリアル運用 (SQEX大阪: 林武尊様) #UE4DD
エピック・ゲームズ・ジャパン Epic Games Japan
 
PDF
怖くないSpring Bootのオートコンフィグレーション
土岐 孝平
 
Unityでオニオンアーキテクチャ
torisoup
 
ObserverパターンからはじめるUniRx
torisoup
 
MagicOnion~C#でゲームサーバを開発しよう~
torisoup
 
Observableで非同期処理
torisoup
 
Unity開発で使える設計の話+Zenjectの紹介
torisoup
 
Unityによるリアルタイム通信とMagicOnionによるC#大統一理論の実現
Yoshifumi Kawai
 
世界一わかりやすいClean Architecture
Atsushi Nakamura
 
【Unity道場Houdini編】Houdini Engine とプロシージャル法
UnityTechnologiesJapan002
 
Unityでオンラインゲーム作った話
torisoup
 
Unityでパフォーマンスの良いUIを作る為のTips
Unity Technologies Japan K.K.
 
Deep Dive async/await in Unity with UniTask(UniRx.Async)
Yoshifumi Kawai
 
Nintendo Switch『OCTOPATH TRAVELER』はこうして作られた
エピック・ゲームズ・ジャパン Epic Games Japan
 
ライブラリ作成のすゝめ - 事例から見る個人OSS開発の効能
Yoshifumi Kawai
 
ソフトウェア開発における『知の高速道路』
Yoshitaka Kawashima
 
【Unite Tokyo 2019】運用中超大規模タイトルにおけるUnityアップデート課題の解決手法と事例
UnityTechnologiesJapan002
 
今日からできる!簡単 .NET 高速化 Tips
Takaaki Suzuki
 
【Unity道場スペシャル 2017博多】クォータニオン完全マスター
Unity Technologies Japan K.K.
 
Reactive extensions入門v0.1
一希 大田
 
大規模タイトルにおけるエフェクトマテリアル運用 (SQEX大阪: 林武尊様) #UE4DD
エピック・ゲームズ・ジャパン Epic Games Japan
 
怖くないSpring Bootのオートコンフィグレーション
土岐 孝平
 

More from Yoshifumi Kawai (20)

PDF
A quick tour of the Cysharp OSS
Yoshifumi Kawai
 
PDF
Building the Game Server both API and Realtime via c#
Yoshifumi Kawai
 
PDF
Unity C#と.NET Core(MagicOnion) C# そしてKotlinによるハーモニー
Yoshifumi Kawai
 
PDF
Implements OpenTelemetry Collector in DotNet
Yoshifumi Kawai
 
PDF
The Usage and Patterns of MagicOnion
Yoshifumi Kawai
 
PDF
True Cloud Native Batch Workflow for .NET with MicroBatchFramework
Yoshifumi Kawai
 
PDF
Memory Management of C# with Unity Native Collections
Yoshifumi Kawai
 
PDF
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
Yoshifumi Kawai
 
PDF
Binary Reading in C#
Yoshifumi Kawai
 
PDF
「黒騎士と白の魔王」gRPCによるHTTP/2 - API, Streamingの実践
Yoshifumi Kawai
 
PPTX
RuntimeUnitTestToolkit for Unity(English)
Yoshifumi Kawai
 
PPTX
RuntimeUnitTestToolkit for Unity
Yoshifumi Kawai
 
PDF
NextGen Server/Client Architecture - gRPC + Unity + C#
Yoshifumi Kawai
 
PDF
How to make the Fastest C# Serializer, In the case of ZeroFormatter
Yoshifumi Kawai
 
PDF
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
Yoshifumi Kawai
 
PDF
ZeroFormatter/MagicOnion - Fastest C# Serializer/gRPC based C# RPC
Yoshifumi Kawai
 
PDF
What, Why, How Create OSS Libraries - 過去に制作した30のライブラリから見るC#コーディングテクニックと個人OSSの...
Yoshifumi Kawai
 
PDF
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Yoshifumi Kawai
 
PDF
Photon Server Deep Dive - PhotonWireの実装から見つめるPhotonServerの基礎と応用
Yoshifumi Kawai
 
PPTX
Clash of Oni Online - VR Multiplay Sword Action
Yoshifumi Kawai
 
A quick tour of the Cysharp OSS
Yoshifumi Kawai
 
Building the Game Server both API and Realtime via c#
Yoshifumi Kawai
 
Unity C#と.NET Core(MagicOnion) C# そしてKotlinによるハーモニー
Yoshifumi Kawai
 
Implements OpenTelemetry Collector in DotNet
Yoshifumi Kawai
 
The Usage and Patterns of MagicOnion
Yoshifumi Kawai
 
True Cloud Native Batch Workflow for .NET with MicroBatchFramework
Yoshifumi Kawai
 
Memory Management of C# with Unity Native Collections
Yoshifumi Kawai
 
CEDEC 2018 最速のC#の書き方 - C#大統一理論へ向けて性能的課題を払拭する
Yoshifumi Kawai
 
Binary Reading in C#
Yoshifumi Kawai
 
「黒騎士と白の魔王」gRPCによるHTTP/2 - API, Streamingの実践
Yoshifumi Kawai
 
RuntimeUnitTestToolkit for Unity(English)
Yoshifumi Kawai
 
RuntimeUnitTestToolkit for Unity
Yoshifumi Kawai
 
NextGen Server/Client Architecture - gRPC + Unity + C#
Yoshifumi Kawai
 
How to make the Fastest C# Serializer, In the case of ZeroFormatter
Yoshifumi Kawai
 
ZeroFormatterに見るC#で最速のシリアライザを作成する100億の方法
Yoshifumi Kawai
 
ZeroFormatter/MagicOnion - Fastest C# Serializer/gRPC based C# RPC
Yoshifumi Kawai
 
What, Why, How Create OSS Libraries - 過去に制作した30のライブラリから見るC#コーディングテクニックと個人OSSの...
Yoshifumi Kawai
 
Photon Server Deep Dive - View from Implmentation of PhotonWire, Multiplayer ...
Yoshifumi Kawai
 
Photon Server Deep Dive - PhotonWireの実装から見つめるPhotonServerの基礎と応用
Yoshifumi Kawai
 
Clash of Oni Online - VR Multiplay Sword Action
Yoshifumi Kawai
 
Ad

Recently uploaded (20)

PDF
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
PDF
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
PDF
Per Axbom: The spectacular lies of maps
Nexer Digital
 
PDF
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PPTX
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
Simple and concise overview about Quantum computing..pptx
mughal641
 
PDF
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
PDF
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
PPTX
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
PDF
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PPTX
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
PPTX
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Generative AI vs Predictive AI-The Ultimate Comparison Guide
Lily Clark
 
Trying to figure out MCP by actually building an app from scratch with open s...
Julien SIMON
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
CIFDAQ's Market Wrap : Bears Back in Control?
CIFDAQ
 
Per Axbom: The spectacular lies of maps
Nexer Digital
 
Make GenAI investments go further with the Dell AI Factory
Principled Technologies
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
AI in Daily Life: How Artificial Intelligence Helps Us Every Day
vanshrpatil7
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Simple and concise overview about Quantum computing..pptx
mughal641
 
Presentation about Hardware and Software in Computer
snehamodhawadiya
 
How Open Source Changed My Career by abdelrahman ismail
a0m0rajab1
 
IT Runs Better with ThousandEyes AI-driven Assurance
ThousandEyes
 
Tea4chat - another LLM Project by Kerem Atam
a0m0rajab1
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
Agentic AI in Healthcare Driving the Next Wave of Digital Transformation
danielle hunter
 
Introduction to Flutter by Ayush Desai.pptx
ayushdesai204
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
A Strategic Analysis of the MVNO Wave in Emerging Markets.pdf
IPLOOK Networks
 
Ad

A Brief History of UniRx/UniTask, IUniTaskSource in Depth

  • 2. 河合 宜文 / Kawai Yoshifumi / @neuecc Cysharp, Inc. Cygames C#大統一理論 C#
  • 4. A Brief History of UniRx/UniTask
  • 9. public readonly struct UniTask<T> { readonly T result; readonly IUniTaskSource<T> source; readonly short token; }
  • 10. public readonly struct UniTask<T> { readonly T result; readonly IUniTaskSource<T> source; readonly short token; }
  • 11. public readonly struct UniTask<T> { readonly T result; readonly IUniTaskSource<T> source; readonly short token; }
  • 12. public interface IUniTaskSource<out T> { T GetResult(short token); UniTaskStatus GetStatus(short token); void OnCompleted(Action<object> continuation, object state, short token); }
  • 13. internal sealed class AsyncUniTask<TStateMachine, T> : IStateMachineRunnerPromise<T>, ITaskPoolNode<AsyncUniTask<TStateMachine, T>>, IUniTaskSource<T> where TStateMachine : IAsyncStateMachine { public static void SetStateMachine(ref TStateMachine stateMachine, ref IStateMachineRunnerPro { // プールから取得する if (!pool.TryPop(out var result)) { result = new AsyncUniTask<TStateMachine, T>(); } } public T GetResult(short token) { try { return core.GetResult(token); } finally { core.Reset(); // core.version++ return pool.TryPush(this); // プールに返す} } }
  • 14. internal sealed class AsyncUniTask<TStateMachine, T> : IStateMachineRunnerPromise<T>, ITaskPoolNode<AsyncUniTask<TStateMachine, T>>, IUniTaskSource<T> where TStateMachine : IAsyncStateMachine { public static void SetStateMachine(ref TStateMachine stateMachine, ref IStateMachineRunnerPro { // プールから取得する if (!pool.TryPop(out var result)) { result = new AsyncUniTask<TStateMachine, T>(); } } public T GetResult(short token) { try { return core.GetResult(token); } finally { core.Reset(); // core.version++ return pool.TryPush(this); // プールに返す} } }
  • 15. public interface IUniTaskSource<out T> { T GetResult(short token); UniTaskStatus GetStatus(short token); void OnCompleted(Action<object> continuation, object state, short token); } public readonly struct UniTask<T> { readonly T result; readonly IUniTaskSource<T> source; readonly short token; }
  • 16. public interface IUniTaskSource<out T> { T GetResult(short token); UniTaskStatus GetStatus(short token); void OnCompleted(Action<object> continuation, object state, short token); } public readonly struct UniTask<T> { readonly T result; readonly IUniTaskSource<T> source; readonly short token; }
  • 17. public interface IUniTaskSource<out T> { T GetResult(short token); UniTaskStatus GetStatus(short token); void OnCompleted(Action<object> continuation, object state, short token); } public readonly struct UniTask<T> { readonly T result; readonly IUniTaskSource<T> source; readonly short token; } if (token != version) { throw new InvalidOperationException( "Token version is not matched, can not await twice or get Status after await.“ ); }
  • 18. sealed class DelayPromise : IUniTaskSource, IPlayerLoopItem, ITaskPoolNode<DelayPromise>