mirror of https://github.com/Cysharp/UniTask
Fix channel's cancellationTokenRegistration does not handle correctly
parent
51ba740413
commit
70385c4115
|
@ -368,8 +368,8 @@ namespace Cysharp.Threading.Tasks
|
||||||
readonly SingleConsumerUnboundedChannelReader parent;
|
readonly SingleConsumerUnboundedChannelReader parent;
|
||||||
CancellationToken cancellationToken1;
|
CancellationToken cancellationToken1;
|
||||||
CancellationToken cancellationToken2;
|
CancellationToken cancellationToken2;
|
||||||
CancellationTokenRegistration CancellationTokenRegistration1;
|
CancellationTokenRegistration cancellationTokenRegistration1;
|
||||||
CancellationTokenRegistration CancellationTokenRegistration2;
|
CancellationTokenRegistration cancellationTokenRegistration2;
|
||||||
|
|
||||||
T current;
|
T current;
|
||||||
bool cacheValue;
|
bool cacheValue;
|
||||||
|
@ -395,12 +395,12 @@ namespace Cysharp.Threading.Tasks
|
||||||
|
|
||||||
if (this.cancellationToken1.CanBeCanceled)
|
if (this.cancellationToken1.CanBeCanceled)
|
||||||
{
|
{
|
||||||
this.cancellationToken1.RegisterWithoutCaptureExecutionContext(CancellationCallback1Delegate, this);
|
this.cancellationTokenRegistration1 = this.cancellationToken1.RegisterWithoutCaptureExecutionContext(CancellationCallback1Delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.cancellationToken2.CanBeCanceled)
|
if (this.cancellationToken2.CanBeCanceled)
|
||||||
{
|
{
|
||||||
this.cancellationToken2.RegisterWithoutCaptureExecutionContext(CancellationCallback2Delegate, this);
|
this.cancellationTokenRegistration2 = this.cancellationToken2.RegisterWithoutCaptureExecutionContext(CancellationCallback2Delegate, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
running = true;
|
running = true;
|
||||||
|
@ -428,8 +428,8 @@ namespace Cysharp.Threading.Tasks
|
||||||
|
|
||||||
public UniTask DisposeAsync()
|
public UniTask DisposeAsync()
|
||||||
{
|
{
|
||||||
CancellationTokenRegistration1.Dispose();
|
cancellationTokenRegistration1.Dispose();
|
||||||
CancellationTokenRegistration2.Dispose();
|
cancellationTokenRegistration2.Dispose();
|
||||||
return default;
|
return default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue