mirror of
https://github.com/Cysharp/UniTask.git
synced 2026-05-20 06:00:11 +00:00
complete except trigger
This commit is contained in:
@@ -1,130 +0,0 @@
|
||||
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
using System;
|
||||
using System.Threading;
|
||||
|
||||
namespace UniRx.Async.Internal
|
||||
{
|
||||
internal sealed class LazyPromise : IAwaiter
|
||||
{
|
||||
Func<UniTask> factory;
|
||||
UniTask value;
|
||||
|
||||
public LazyPromise(Func<UniTask> factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
void Create()
|
||||
{
|
||||
var f = Interlocked.Exchange(ref factory, null);
|
||||
if (f != null)
|
||||
{
|
||||
value = f();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
Create();
|
||||
return value.IsCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
public UniTaskStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
Create();
|
||||
return value.Status;
|
||||
}
|
||||
}
|
||||
|
||||
public void GetResult()
|
||||
{
|
||||
Create();
|
||||
value.GetResult();
|
||||
}
|
||||
|
||||
void IAwaiter.GetResult()
|
||||
{
|
||||
GetResult();
|
||||
}
|
||||
|
||||
public void UnsafeOnCompleted(Action continuation)
|
||||
{
|
||||
Create();
|
||||
value.GetAwaiter().UnsafeOnCompleted(continuation);
|
||||
}
|
||||
|
||||
public void OnCompleted(Action continuation)
|
||||
{
|
||||
UnsafeOnCompleted(continuation);
|
||||
}
|
||||
}
|
||||
|
||||
internal sealed class LazyPromise<T> : IAwaiter<T>
|
||||
{
|
||||
Func<UniTask<T>> factory;
|
||||
UniTask<T> value;
|
||||
|
||||
public LazyPromise(Func<UniTask<T>> factory)
|
||||
{
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
void Create()
|
||||
{
|
||||
var f = Interlocked.Exchange(ref factory, null);
|
||||
if (f != null)
|
||||
{
|
||||
value = f();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsCompleted
|
||||
{
|
||||
get
|
||||
{
|
||||
Create();
|
||||
return value.IsCompleted;
|
||||
}
|
||||
}
|
||||
|
||||
public UniTaskStatus Status
|
||||
{
|
||||
get
|
||||
{
|
||||
Create();
|
||||
return value.Status;
|
||||
}
|
||||
}
|
||||
|
||||
public T GetResult()
|
||||
{
|
||||
Create();
|
||||
return value.Result;
|
||||
}
|
||||
|
||||
void IAwaiter.GetResult()
|
||||
{
|
||||
GetResult();
|
||||
}
|
||||
|
||||
public void UnsafeOnCompleted(Action continuation)
|
||||
{
|
||||
Create();
|
||||
value.GetAwaiter().UnsafeOnCompleted(continuation);
|
||||
}
|
||||
|
||||
public void OnCompleted(Action continuation)
|
||||
{
|
||||
UnsafeOnCompleted(continuation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -8,7 +8,8 @@ using System.Runtime.CompilerServices;
|
||||
namespace UniRx.Async.Internal
|
||||
{
|
||||
// optimized version of Standard Queue<T>.
|
||||
internal class MinimumQueue<T>
|
||||
// TODO: to internal.
|
||||
public class MinimumQueue<T>
|
||||
{
|
||||
const int MinimumGrow = 4;
|
||||
const int GrowFactor = 200;
|
||||
@@ -28,7 +29,7 @@ namespace UniRx.Async.Internal
|
||||
public int Count
|
||||
{
|
||||
#if NET_4_6 || NET_STANDARD_2_0
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
#endif
|
||||
get { return size; }
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe7a4187b7f89f84582fd1e466a7f27e
|
||||
guid: 60cdf0bcaea36b444a7ae7263ae7598f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
Reference in New Issue
Block a user