Skip to content

Commit b84ff4c

Browse files
committed
save
1 parent 9ee7181 commit b84ff4c

File tree

236 files changed

+26519
-9707
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

236 files changed

+26519
-9707
lines changed

Web3/Assets/EasyWeb3/Lib/UniRx.Async.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
2+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or
3+
4+
using System;
5+
6+
namespace UniRx.Async
7+
{
8+
public struct AsyncUnit : IEquatable<AsyncUnit>
9+
{
10+
public static readonly AsyncUnit Default = new AsyncUnit();
11+
12+
public override int GetHashCode()
13+
{
14+
return 0;
15+
}
16+
17+
public bool Equals(AsyncUnit other)
18+
{
19+
return true;
20+
}
21+
22+
public override string ToString()
23+
{
24+
return "()";
25+
}
26+
}
27+
}
28+
#endif

Web3/Assets/EasyWeb3/Lib/UniRx.Async/AsyncUnit.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
2+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
3+
4+
using System.Collections.Generic;
5+
using System.Threading;
6+
7+
namespace UniRx.Async
8+
{
9+
public class CancellationTokenEqualityComparer : IEqualityComparer<CancellationToken>
10+
{
11+
public static readonly IEqualityComparer<CancellationToken> Default = new CancellationTokenEqualityComparer();
12+
13+
public bool Equals(CancellationToken x, CancellationToken y)
14+
{
15+
return x.Equals(y);
16+
}
17+
18+
public int GetHashCode(CancellationToken obj)
19+
{
20+
return obj.GetHashCode();
21+
}
22+
}
23+
}
24+
25+
#endif

Web3/Assets/EasyWeb3/Lib/UniRx.Async/CancellationTokenEqualityComparer.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
2+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
3+
4+
using System;
5+
using System.Threading;
6+
7+
namespace UniRx.Async
8+
{
9+
public static class CancellationTokenExtensions
10+
{
11+
static readonly Action<object> cancellationTokenCallback = Callback;
12+
13+
public static (UniTask, CancellationTokenRegistration) ToUniTask(this CancellationToken cts)
14+
{
15+
if (cts.IsCancellationRequested)
16+
{
17+
return (UniTask.FromCanceled(cts), default(CancellationTokenRegistration));
18+
}
19+
20+
var promise = new UniTaskCompletionSource<AsyncUnit>();
21+
return (promise.Task, cts.RegisterWithoutCaptureExecutionContext(cancellationTokenCallback, promise));
22+
}
23+
24+
static void Callback(object state)
25+
{
26+
var promise = (UniTaskCompletionSource<AsyncUnit>)state;
27+
promise.TrySetResult(AsyncUnit.Default);
28+
}
29+
30+
public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action callback)
31+
{
32+
var restoreFlow = false;
33+
if (!ExecutionContext.IsFlowSuppressed())
34+
{
35+
ExecutionContext.SuppressFlow();
36+
restoreFlow = true;
37+
}
38+
39+
try
40+
{
41+
return cancellationToken.Register(callback, false);
42+
}
43+
finally
44+
{
45+
if (restoreFlow)
46+
{
47+
ExecutionContext.RestoreFlow();
48+
}
49+
}
50+
}
51+
52+
public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action<object> callback, object state)
53+
{
54+
var restoreFlow = false;
55+
if (!ExecutionContext.IsFlowSuppressed())
56+
{
57+
ExecutionContext.SuppressFlow();
58+
restoreFlow = true;
59+
}
60+
61+
try
62+
{
63+
return cancellationToken.Register(callback, state, false);
64+
}
65+
finally
66+
{
67+
if (restoreFlow)
68+
{
69+
ExecutionContext.RestoreFlow();
70+
}
71+
}
72+
}
73+
}
74+
}
75+
76+
#endif

Web3/Assets/EasyWeb3/Lib/UniRx.Async/CancellationTokenExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#if CSHARP_7_OR_LATER || (UNITY_2018_3_OR_NEWER && (NET_STANDARD_2_0 || NET_4_6))
2+
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
3+
4+
using System.Threading;
5+
using UnityEngine;
6+
using UniRx.Async.Triggers;
7+
using System;
8+
9+
namespace UniRx.Async
10+
{
11+
public static class CancellationTokenSourceExtensions
12+
{
13+
public static void CancelAfterSlim(this CancellationTokenSource cts, int millisecondsDelay, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update)
14+
{
15+
var delay = UniTask.Delay(millisecondsDelay, ignoreTimeScale, delayTiming, cts.Token);
16+
CancelAfterCore(cts, delay).Forget();
17+
}
18+
19+
public static void CancelAfterSlim(this CancellationTokenSource cts, TimeSpan delayTimeSpan, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update)
20+
{
21+
var delay = UniTask.Delay(delayTimeSpan, ignoreTimeScale, delayTiming, cts.Token);
22+
CancelAfterCore(cts, delay).Forget();
23+
}
24+
25+
static async UniTaskVoid CancelAfterCore(CancellationTokenSource cts, UniTask delayTask)
26+
{
27+
var alreadyCanceled = await delayTask.SuppressCancellationThrow();
28+
if (!alreadyCanceled)
29+
{
30+
cts.Cancel();
31+
cts.Dispose();
32+
}
33+
}
34+
35+
public static void RegisterRaiseCancelOnDestroy(this CancellationTokenSource cts, Component component)
36+
{
37+
RegisterRaiseCancelOnDestroy(cts, component.gameObject);
38+
}
39+
40+
public static void RegisterRaiseCancelOnDestroy(this CancellationTokenSource cts, GameObject gameObject)
41+
{
42+
var trigger = gameObject.GetAsyncDestroyTrigger();
43+
trigger.AddCancellationTriggerOnDestory(cts);
44+
}
45+
}
46+
}
47+
48+
#endif

Web3/Assets/EasyWeb3/Lib/UniRx.Async/CancellationTokenSourceExtensions.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Web3/Assets/EasyWeb3/Lib/UniRx.Async/CompilerServices.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)