mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-26 18:10:17 +00:00
guard for trigger invalid ops
This commit is contained in:
@@ -24,7 +24,6 @@ namespace Cysharp.Threading.Tasks
|
|||||||
bool preserveRemoveSelf;
|
bool preserveRemoveSelf;
|
||||||
ITriggerHandler<T> iteratingNode;
|
ITriggerHandler<T> iteratingNode;
|
||||||
|
|
||||||
|
|
||||||
void LogError(Exception ex)
|
void LogError(Exception ex)
|
||||||
{
|
{
|
||||||
#if UNITY_2018_3_OR_NEWER
|
#if UNITY_2018_3_OR_NEWER
|
||||||
@@ -36,6 +35,11 @@ namespace Cysharp.Threading.Tasks
|
|||||||
|
|
||||||
public void SetResult(T value)
|
public void SetResult(T value)
|
||||||
{
|
{
|
||||||
|
if (iteratingNode != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Can not trigger itself in iterating.");
|
||||||
|
}
|
||||||
|
|
||||||
var h = head;
|
var h = head;
|
||||||
while (h != null)
|
while (h != null)
|
||||||
{
|
{
|
||||||
@@ -75,6 +79,11 @@ namespace Cysharp.Threading.Tasks
|
|||||||
|
|
||||||
public void SetCanceled(CancellationToken cancellationToken)
|
public void SetCanceled(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
|
if (iteratingNode != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Can not trigger itself in iterating.");
|
||||||
|
}
|
||||||
|
|
||||||
var h = head;
|
var h = head;
|
||||||
while (h != null)
|
while (h != null)
|
||||||
{
|
{
|
||||||
@@ -105,6 +114,11 @@ namespace Cysharp.Threading.Tasks
|
|||||||
|
|
||||||
public void SetCompleted()
|
public void SetCompleted()
|
||||||
{
|
{
|
||||||
|
if (iteratingNode != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Can not trigger itself in iterating.");
|
||||||
|
}
|
||||||
|
|
||||||
var h = head;
|
var h = head;
|
||||||
while (h != null)
|
while (h != null)
|
||||||
{
|
{
|
||||||
@@ -135,6 +149,11 @@ namespace Cysharp.Threading.Tasks
|
|||||||
|
|
||||||
public void SetError(Exception exception)
|
public void SetError(Exception exception)
|
||||||
{
|
{
|
||||||
|
if (iteratingNode != null)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException("Can not trigger itself in iterating.");
|
||||||
|
}
|
||||||
|
|
||||||
var h = head;
|
var h = head;
|
||||||
while (h != null)
|
while (h != null)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user