Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs #10

Merged
merged 1 commit into from
Dec 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/en/TaskInterval/player-loop.html.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion docs/en/TaskQueue/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,9 @@ <h4 id="execution-result">Execution Result</h4>
<h3 id="executing-priority-tasks">Executing Priority Tasks</h3>
<p>You can execute priority tasks by specifying the priority as the second argument to Enqueue.
The processing with a smaller <code>priority</code> value is prioritized. The default value is 0.</p>
<pre><code class="lang-csharp">taskQueue.Enqueue(async ct =&gt; { ... }, priority: 1);
<pre><code class="lang-csharp">taskQueue = new TaskQueue();
taskQueue.Start();
taskQueue.Enqueue(async ct =&gt; { ... }, priority: 1);
taskQueue.Enqueue(async ct =&gt; { ... }, priority: 0); // This task is processed first
</code></pre>
<h3 id="setting-the-maximum-queue-size">Setting the Maximum Queue Size</h3>
Expand All @@ -141,6 +143,7 @@ <h4 id="taskqueuelimittypediscard">TaskQueueLimitType.Discard</h4>
and exceed the maximum number, the last added task is discarded.
If the priority of the task to be added is higher, the task with a lower priority is discarded and queued.</p>
<pre><code class="lang-csharp">taskQueue = new TaskQueue(TaskQueueLimitType.Discard, maxSize: 2);
taskQueue.Start();
taskQueue.Enqueue(async ct =&gt; { ... });
taskQueue.Enqueue(async ct =&gt; { ... });
taskQueue.Enqueue(async ct =&gt; { ... }); // This task is discarded
Expand All @@ -150,6 +153,7 @@ <h4 id="taskqueuelimittypeswaplast">TaskQueueLimitType.SwapLast</h4>
and exceed the maximum number, the last task is replaced.
If the queue is made up of tasks that have a higher priority than the task to be added, no replacement will be made.</p>
<pre><code class="lang-csharp">taskQueue = new TaskQueue(TaskQueueLimitType.SwapLast, maxSize: 2);
taskQueue.Start();
taskQueue.Enqueue(async ct =&gt; { ... });
taskQueue.Enqueue(async ct =&gt; { ... }); // This task is discarded
taskQueue.Enqueue(async ct =&gt; { ... });
Expand Down
7 changes: 7 additions & 0 deletions docs/en/TaskQueue/player-loop.html.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docs/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@
"en/TaskQueue/index.html": {
"href": "en/TaskQueue/index.html",
"title": "TaskQueue | MewCore",
"keywords": "TaskQueue TaskQueue is a library for handling serial processing of asynchronous functions in Unity development. Asynchronous functions are executed in the order they are input into the queue. It also has the feature of a priority queue, which allows you to prioritize important tasks. Main Features Dynamic Function Addition: You can add asynchronous functions to the task queue at runtime. This allows you to flexibly respond to changing requirements and situations. Execution management based on priority: You can set a priority for each asynchronous function and process important tasks preferentially. This prevents delays in important processing. Serial processing and safety: Multiple asynchronous functions are executed in order and wait for the completion of one function before starting the execution of the next. This improves the safety of UI updates and game sequences. Maximum size of the queue: You can set the maximum number of tasks that can be input into the queue. This allows you to prevent tasks from building up in the queue. Use Scenarios Dynamic UI Updates: Used for smooth control of dynamic display and hiding of dialog boxes and menus in the game. Game Event Sequencing: Suitable for managing ordered events such as story progression and tutorials. Command Pattern Adaptation: Suitable for implementing the command pattern, including asynchronous processes. UI Event Handling: Used to prevent concurrent execution in response to asynchronous UI events such as clicks. Sample Code class Sample : Monobehaviour { void Start() { var taskQueue = new TaskQueue(); // By passing the destroyCancellationToken, processing is automatically stoppped and disposed when MonoBehaviour is destroyed. taskQueue.Start(destroyCancellationToken); // Add an asynchronous function to TaskQueue. taskQueue.Enqueue(async cancellationToken => { Debug.Log(\"Hello\"); await Task.Delay(1000, cancellationToken); }); taskQueue.Enqueue(async cancellationToken => { await Task.Delay(1000, cancellationToken); Debug.Log(\"Bye\"); }); } } Execution Result Hello // 2sec later Bye Executing Priority Tasks You can execute priority tasks by specifying the priority as the second argument to Enqueue. The processing with a smaller priority value is prioritized. The default value is 0. taskQueue.Enqueue(async ct => { ... }, priority: 1); taskQueue.Enqueue(async ct => { ... }, priority: 0); // This task is processed first Setting the Maximum Queue Size TaskQueueLimitType.Discard If you add tasks to a queue with a maximum size of 2 as follows, and exceed the maximum number, the last added task is discarded. If the priority of the task to be added is higher, the task with a lower priority is discarded and queued. taskQueue = new TaskQueue(TaskQueueLimitType.Discard, maxSize: 2); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // This task is discarded TaskQueueLimitType.SwapLast If you add tasks to a queue with a maximum size of 2 as follows, and exceed the maximum number, the last task is replaced. If the queue is made up of tasks that have a higher priority than the task to be added, no replacement will be made. taskQueue = new TaskQueue(TaskQueueLimitType.SwapLast, maxSize: 2); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // This task is discarded taskQueue.Enqueue(async ct => { ... });"
"keywords": "TaskQueue TaskQueue is a library for handling serial processing of asynchronous functions in Unity development. Asynchronous functions are executed in the order they are input into the queue. It also has the feature of a priority queue, which allows you to prioritize important tasks. Main Features Dynamic Function Addition: You can add asynchronous functions to the task queue at runtime. This allows you to flexibly respond to changing requirements and situations. Execution management based on priority: You can set a priority for each asynchronous function and process important tasks preferentially. This prevents delays in important processing. Serial processing and safety: Multiple asynchronous functions are executed in order and wait for the completion of one function before starting the execution of the next. This improves the safety of UI updates and game sequences. Maximum size of the queue: You can set the maximum number of tasks that can be input into the queue. This allows you to prevent tasks from building up in the queue. Use Scenarios Dynamic UI Updates: Used for smooth control of dynamic display and hiding of dialog boxes and menus in the game. Game Event Sequencing: Suitable for managing ordered events such as story progression and tutorials. Command Pattern Adaptation: Suitable for implementing the command pattern, including asynchronous processes. UI Event Handling: Used to prevent concurrent execution in response to asynchronous UI events such as clicks. Sample Code class Sample : Monobehaviour { void Start() { var taskQueue = new TaskQueue(); // By passing the destroyCancellationToken, processing is automatically stoppped and disposed when MonoBehaviour is destroyed. taskQueue.Start(destroyCancellationToken); // Add an asynchronous function to TaskQueue. taskQueue.Enqueue(async cancellationToken => { Debug.Log(\"Hello\"); await Task.Delay(1000, cancellationToken); }); taskQueue.Enqueue(async cancellationToken => { await Task.Delay(1000, cancellationToken); Debug.Log(\"Bye\"); }); } } Execution Result Hello // 2sec later Bye Executing Priority Tasks You can execute priority tasks by specifying the priority as the second argument to Enqueue. The processing with a smaller priority value is prioritized. The default value is 0. taskQueue = new TaskQueue(); taskQueue.Start(); taskQueue.Enqueue(async ct => { ... }, priority: 1); taskQueue.Enqueue(async ct => { ... }, priority: 0); // This task is processed first Setting the Maximum Queue Size TaskQueueLimitType.Discard If you add tasks to a queue with a maximum size of 2 as follows, and exceed the maximum number, the last added task is discarded. If the priority of the task to be added is higher, the task with a lower priority is discarded and queued. taskQueue = new TaskQueue(TaskQueueLimitType.Discard, maxSize: 2); taskQueue.Start(); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // This task is discarded TaskQueueLimitType.SwapLast If you add tasks to a queue with a maximum size of 2 as follows, and exceed the maximum number, the last task is replaced. If the queue is made up of tasks that have a higher priority than the task to be added, no replacement will be made. taskQueue = new TaskQueue(TaskQueueLimitType.SwapLast, maxSize: 2); taskQueue.Start(); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // This task is discarded taskQueue.Enqueue(async ct => { ... });"
},
"en/TaskQueue/player-loop.html": {
"href": "en/TaskQueue/player-loop.html",
Expand Down Expand Up @@ -182,7 +182,7 @@
"ja/TaskQueue/index.html": {
"href": "ja/TaskQueue/index.html",
"title": "TaskQueue | MewCore",
"keywords": "TaskQueue TaskQueue は Unity 開発における非同期関数の直列処理を行うためのライブラリです。 キューに入力した順で非同期関数が実行されます。 また、優先度付きキューの機能も備えており、重要なタスクを優先的に実行することができます。 主な特徴 動的な関数追加: ランタイムで非同期関数をタスクキューに追加することができます。これにより、変化する要件や状況に柔軟に対応可能です。 優先度に基づく実行管理: 各非同期関数に優先度を設定し、重要なタスクを優先的に処理します。これにより、重要な処理の遅延を防ぎます。 直列処理と安全性: 複数の非同期関数を順序立てて実行し、一つの関数が完了するまで次の関数の実行を待機します。これにより、UI 更新やゲームシーケンスの安全性が向上します。 キューの最大サイズ: キューに入力できるタスクの最大数を設定できます。これにより、キューにタスクが溜まりすぎることを防ぐことができます。 シンプルな記述: シンプルに記述できるように設計されています。 使用シナリオ UIの動的更新: ゲーム内でのダイアログボックスやメニューの動的な表示・非表示をスムーズに制御する際に使用します。 ゲームイベントのシーケンシング: 物語進行やチュートリアルなど、順序立てられたイベントの管理に適しています。 TaskQueue を使用することで、Unity 開発における非同期処理の複雑さを軽減し、より効果的かつ効率的なコード記述を可能にします。 コマンドパターンへの適応: 非同期処理を含めたコマンドパターンの実装に適しています。 UI イベントのハンドリング: クリックなど UI の非同期イベントに対して並列実行を防ぐために使用します。 サンプルコード class Sample : Monobehaviour { void Start() { var taskQueue = new TaskQueue(); // destroyCancellationToken を渡すことで // MonoBehaviour が破棄されたタイミングで自動的に処理を停止し Dispose されます。 taskQueue.Start(destroyCancellationToken); // TaskQueue に非同期関数を追加します。 taskQueue.Enqueue(async cancellationToken => { Debug.Log(\"Hello\"); await Task.Delay(1000, cancellationToken); }); taskQueue.Enqueue(async cancellationToken => { await Task.Delay(1000, cancellationToken); Debug.Log(\"Bye\"); }); } } 実行結果 Hello // 二秒後 Bye 優先度付きタスクの実行 Enqueue の第二引数に優先度を指定することで、優先度付きタスクを実行することができます。 priotiry値が小さい処理が優先されます。既定値は 0 です。 taskQueue.Enqueue(async ct => { ... }, priority: 1); taskQueue.Enqueue(async ct => { ... }, priority: 0); // このタスクが優先して処理される キュー最大サイズの設定 TaskQueueLimitType.Discard 最大サイズ 2 のキューに対して以下のようにタスクを追加し、最大数を超えた場合、最後に追加されたタスクが破棄されます。 追加されるタスクの優先度が高い場合は、より低い優先度のタスクが破棄されキューイングが行われます。 taskQueue = new TaskQueue(TaskQueueLimitType.Discard, maxSize: 2); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // このタスクが破棄される TaskQueueLimitType.SwapLast 最大サイズ 2 のキューに対して以下のようにタスクを追加し、最大数を超えた場合、最後のタスクを入れ替えます。 追加されるタスクより優先度が高いタスクでキューが構成される場合は、入れ替えは行われません。 taskQueue = new TaskQueue(TaskQueueLimitType.SwapLast, maxSize: 2); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // このタスクが破棄される taskQueue.Enqueue(async ct => { ... });"
"keywords": "TaskQueue TaskQueue は Unity 開発における非同期関数の直列処理を行うためのライブラリです。 キューに入力した順で非同期関数が実行されます。 また、優先度付きキューの機能も備えており、重要なタスクを優先的に実行することができます。 主な特徴 動的な関数追加: ランタイムで非同期関数をタスクキューに追加することができます。これにより、変化する要件や状況に柔軟に対応可能です。 優先度に基づく実行管理: 各非同期関数に優先度を設定し、重要なタスクを優先的に処理します。これにより、重要な処理の遅延を防ぎます。 直列処理と安全性: 複数の非同期関数を順序立てて実行し、一つの関数が完了するまで次の関数の実行を待機します。これにより、UI 更新やゲームシーケンスの安全性が向上します。 キューの最大サイズ: キューに入力できるタスクの最大数を設定できます。これにより、キューにタスクが溜まりすぎることを防ぐことができます。 シンプルな記述: シンプルに記述できるように設計されています。 使用シナリオ UIの動的更新: ゲーム内でのダイアログボックスやメニューの動的な表示・非表示をスムーズに制御する際に使用します。 ゲームイベントのシーケンシング: 物語進行やチュートリアルなど、順序立てられたイベントの管理に適しています。 TaskQueue を使用することで、Unity 開発における非同期処理の複雑さを軽減し、より効果的かつ効率的なコード記述を可能にします。 コマンドパターンへの適応: 非同期処理を含めたコマンドパターンの実装に適しています。 UI イベントのハンドリング: クリックなど UI の非同期イベントに対して並列実行を防ぐために使用します。 サンプルコード class Sample : Monobehaviour { void Start() { var taskQueue = new TaskQueue(); // destroyCancellationToken を渡すことで // MonoBehaviour が破棄されたタイミングで自動的に処理を停止し Dispose されます。 taskQueue.Start(destroyCancellationToken); // TaskQueue に非同期関数を追加します。 taskQueue.Enqueue(async cancellationToken => { Debug.Log(\"Hello\"); await Task.Delay(1000, cancellationToken); }); taskQueue.Enqueue(async cancellationToken => { await Task.Delay(1000, cancellationToken); Debug.Log(\"Bye\"); }); } } 実行結果 Hello // 二秒後 Bye 優先度付きタスクの実行 Enqueue の第二引数に優先度を指定することで、優先度付きタスクを実行することができます。 priotiry値が小さい処理が優先されます。既定値は 0 です。 taskQueue = new TaskQueue(); taskQueue.Start(); taskQueue.Enqueue(async ct => { ... }, priority: 1); taskQueue.Enqueue(async ct => { ... }, priority: 0); // このタスクが優先して処理される キュー最大サイズの設定 TaskQueueLimitType.Discard 最大サイズ 2 のキューに対して以下のようにタスクを追加し、最大数を超えた場合、最後に追加されたタスクが破棄されます。 追加されるタスクの優先度が高い場合は、より低い優先度のタスクが破棄されキューイングが行われます。 taskQueue = new TaskQueue(TaskQueueLimitType.Discard, maxSize: 2); taskQueue.Start(); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // このタスクが破棄される TaskQueueLimitType.SwapLast 最大サイズ 2 のキューに対して以下のようにタスクを追加し、最大数を超えた場合、最後のタスクを入れ替えます。 追加されるタスクより優先度が高いタスクでキューが構成される場合は、入れ替えは行われません。 taskQueue = new TaskQueue(TaskQueueLimitType.SwapLast, maxSize: 2); taskQueue.Start(); taskQueue.Enqueue(async ct => { ... }); taskQueue.Enqueue(async ct => { ... }); // このタスクが破棄される taskQueue.Enqueue(async ct => { ... });"
},
"ja/TaskQueue/player-loop.html": {
"href": "ja/TaskQueue/player-loop.html",
Expand Down
7 changes: 7 additions & 0 deletions docs/ja/TaskInterval/player-loop.html.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion docs/ja/TaskQueue/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,17 @@ <h4 id="実行結果">実行結果</h4>
<h3 id="優先度付きタスクの実行">優先度付きタスクの実行</h3>
<p>Enqueue の第二引数に優先度を指定することで、優先度付きタスクを実行することができます。
<code>priotiry</code>値が小さい処理が優先されます。既定値は 0 です。</p>
<pre><code class="lang-csharp">taskQueue.Enqueue(async ct =&gt; { ... }, priority: 1);
<pre><code class="lang-csharp">taskQueue = new TaskQueue();
taskQueue.Start();
taskQueue.Enqueue(async ct =&gt; { ... }, priority: 1);
taskQueue.Enqueue(async ct =&gt; { ... }, priority: 0); // このタスクが優先して処理される
</code></pre>
<h3 id="キュー最大サイズの設定">キュー最大サイズの設定</h3>
<h4 id="taskqueuelimittypediscard">TaskQueueLimitType.Discard</h4>
<p>最大サイズ 2 のキューに対して以下のようにタスクを追加し、最大数を超えた場合、最後に追加されたタスクが破棄されます。
追加されるタスクの優先度が高い場合は、より低い優先度のタスクが破棄されキューイングが行われます。</p>
<pre><code class="lang-csharp">taskQueue = new TaskQueue(TaskQueueLimitType.Discard, maxSize: 2);
taskQueue.Start();
taskQueue.Enqueue(async ct =&gt; { ... });
taskQueue.Enqueue(async ct =&gt; { ... });
taskQueue.Enqueue(async ct =&gt; { ... }); // このタスクが破棄される
Expand All @@ -153,6 +156,7 @@ <h4 id="taskqueuelimittypeswaplast">TaskQueueLimitType.SwapLast</h4>
<p>最大サイズ 2 のキューに対して以下のようにタスクを追加し、最大数を超えた場合、最後のタスクを入れ替えます。
追加されるタスクより優先度が高いタスクでキューが構成される場合は、入れ替えは行われません。</p>
<pre><code class="lang-csharp">taskQueue = new TaskQueue(TaskQueueLimitType.SwapLast, maxSize: 2);
taskQueue.Start();
taskQueue.Enqueue(async ct =&gt; { ... });
taskQueue.Enqueue(async ct =&gt; { ... }); // このタスクが破棄される
taskQueue.Enqueue(async ct =&gt; { ... }); 
Expand Down
Loading