Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Prev Previous commit
Next Next commit
Update uniRX, selector and sequencer streams and tests added
  • Loading branch information
MystikalPooka committed Dec 23, 2018
commit 8af314cf4ad6c0446761cfff424cb51deb50d0d4
2 changes: 0 additions & 2 deletions Assets/Plugins/UniRx.meta

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

2 changes: 0 additions & 2 deletions Assets/Plugins/UniRx/Examples.meta

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

8 changes: 8 additions & 0 deletions Assets/Plugins/UniRx/Examples/Sample01_ObservableWWW.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#if !(UNITY_METRO || UNITY_WP8)

#if UNITY_2018_3_OR_NEWER
#pragma warning disable CS0618
#endif

using UnityEngine;

namespace UniRx.Examples
Expand Down Expand Up @@ -79,4 +83,8 @@ from bing in ObservableWWW.Get("http://bing.com/")
}
}

#endif

#if UNITY_2018_3_OR_NEWER
#pragma warning restore CS0618
#endif

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

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

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

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

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
using System.Collections;
using System.Threading;
using UnityEngine;
#if UNITY_2018_3_OR_NEWER
#pragma warning disable CS0618
#endif

namespace UniRx.Examples
{
Expand Down Expand Up @@ -36,4 +39,7 @@ static IEnumerator GetWWWCore(string url, IObserver<string> observer, Cancellati
}
}
}
}
}
#if UNITY_2018_3_OR_NEWER
#pragma warning restore CS0618
#endif

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

7 changes: 6 additions & 1 deletion Assets/Plugins/UniRx/Examples/Sample06_ConvertToCoroutine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ IEnumerator ComplexCoroutineTest()
// You can use ToYieldInstruction.

#if !(UNITY_4_0 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2)
#if UNITY_2018_3_OR_NEWER
#pragma warning disable CS0618
#endif

IEnumerator TestNewCustomYieldInstruction()
{
Expand All @@ -50,7 +53,9 @@ IEnumerator TestNewCustomYieldInstruction()
// other sample(wait until transform.position.y >= 100)
yield return this.ObserveEveryValueChanged(x => x.transform).FirstOrDefault(x => x.position.y >= 100).ToYieldInstruction();
}

#if UNITY_2018_3_OR_NEWER
#pragma warning restore CS0618
#endif
#endif

}
Expand Down

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

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

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

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

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

2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/Examples/Sample11_Logger.cs.meta

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

2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/Examples/Sample12Scene.unity.meta

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

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

2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/Examples/Sample13Scene.unity.meta

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

2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/Examples/Sample13_ToDoApp.cs.meta

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

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

2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/ReadMe.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
UniRx - Reactive Extensions for Unity / Ver 6.2.0
UniRx - Reactive Extensions for Unity / Ver 6.2.2
===
Created by Yoshifumi Kawai(neuecc)

Expand Down
2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/ReadMe.txt.meta

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

2 changes: 0 additions & 2 deletions Assets/Plugins/UniRx/Scripts.meta

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

2 changes: 0 additions & 2 deletions Assets/Plugins/UniRx/Scripts/Async.meta

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

2 changes: 1 addition & 1 deletion Assets/Plugins/UniRx/Scripts/Async/AsyncUnit.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER
#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

using System;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
#if (CSHARP_7_OR_LATER)
#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.Collections.Generic;
using System.Threading;

Expand Down
48 changes: 46 additions & 2 deletions Assets/Plugins/UniRx/Scripts/Async/CancellationTokenExtensions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER
#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;
Expand All @@ -18,14 +18,58 @@ public static (UniTask, CancellationTokenRegistration) ToUniTask(this Cancellati
}

var promise = new UniTaskCompletionSource<AsyncUnit>();
return (promise.Task, cts.Register(cancellationTokenCallback, promise, false));
return (promise.Task, cts.RegisterWithoutCaptureExecutionContext(cancellationTokenCallback, promise));
}

static void Callback(object state)
{
var promise = (UniTaskCompletionSource<AsyncUnit>)state;
promise.TrySetResult(AsyncUnit.Default);
}

public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action callback)
{
var restoreFlow = false;
if (!ExecutionContext.IsFlowSuppressed())
{
ExecutionContext.SuppressFlow();
restoreFlow = true;
}

try
{
return cancellationToken.Register(callback, false);
}
finally
{
if (restoreFlow)
{
ExecutionContext.RestoreFlow();
}
}
}

public static CancellationTokenRegistration RegisterWithoutCaptureExecutionContext(this CancellationToken cancellationToken, Action<object> callback, object state)
{
var restoreFlow = false;
if (!ExecutionContext.IsFlowSuppressed())
{
ExecutionContext.SuppressFlow();
restoreFlow = true;
}

try
{
return cancellationToken.Register(callback, state, false);
}
finally
{
if (restoreFlow)
{
ExecutionContext.RestoreFlow();
}
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER
#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.Threading;
Expand All @@ -12,20 +12,24 @@ public static class CancellationTokenSourceExtensions
{
public static void CancelAfterSlim(this CancellationTokenSource cts, int millisecondsDelay, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update)
{
var delay = UniTask.Delay(millisecondsDelay, ignoreTimeScale, delayTiming);
var delay = UniTask.Delay(millisecondsDelay, ignoreTimeScale, delayTiming, cts.Token);
CancelAfterCore(cts, delay).Forget();
}

public static void CancelAfterSlim(this CancellationTokenSource cts, TimeSpan delayTimeSpan, bool ignoreTimeScale = false, PlayerLoopTiming delayTiming = PlayerLoopTiming.Update)
{
var delay = UniTask.Delay(delayTimeSpan, ignoreTimeScale, delayTiming);
var delay = UniTask.Delay(delayTimeSpan, ignoreTimeScale, delayTiming, cts.Token);
CancelAfterCore(cts, delay).Forget();
}

static async UniTaskVoid CancelAfterCore(CancellationTokenSource cts, UniTask delayTask)
{
await delayTask;
cts.Cancel();
var alreadyCanceled = await delayTask.SuppressCancellationThrow();
if (!alreadyCanceled)
{
cts.Cancel();
cts.Dispose();
}
}

public static void RegisterRaiseCancelOnDestroy(this CancellationTokenSource cts, Component component)
Expand Down
2 changes: 0 additions & 2 deletions Assets/Plugins/UniRx/Scripts/Async/CompilerServices.meta

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

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER
#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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER
#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

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if CSHARP_7_OR_LATER
#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

Expand Down
Loading