Skip to content

Commit

Permalink
Merge branch 'hotfix/0.9.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Arvtesh committed May 7, 2018
2 parents 564607d + 48aeab4 commit 6418115
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 17 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/); this project adheres to [Semantic Versioning](http://semver.org/).

-----------------------
## [0.9.0] - Unreleased
## [0.9.2] - Unreleased

-----------------------
## [0.9.1] - 2018.05.07

### Fixed
- Fixed Unity3d script compile errors when targeting .NET 4.x ([Issue #1](https://github.com/Arvtesh/UnityFx.Async/issues/1)).

-----------------------
## [0.9.0] - 2018.04.24

### Added
- Added `AsyncContinuationOptions`.
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
Channel | UnityFx.Async |
---------|---------------|
AppVeyor | [![Build status](https://ci.appveyor.com/api/projects/status/hfmq9vow53al7tpd/branch/master?svg=true)](https://ci.appveyor.com/project/Arvtesh/unityfx-async/branch/master) [![AppVeyor tests](https://img.shields.io/appveyor/tests/Arvtesh/unityFx-async.svg)](https://ci.appveyor.com/project/Arvtesh/unityfx-async/build/tests)
NuGet | [![NuGet](https://img.shields.io/nuget/v/UnityFx.Async.svg)](https://www.nuget.org/packages/UnityFx.Async) [![NuGet](https://img.shields.io/nuget/vpre/UnityFx.Async.svg)](https://www.nuget.org/packages/UnityFx.Async)
NuGet | [![NuGet](https://img.shields.io/nuget/v/UnityFx.Async.svg)](https://www.nuget.org/packages/UnityFx.Async)
Github | [![GitHub release](https://img.shields.io/github/release/Arvtesh/UnityFx.Async.svg?logo=github)](https://github.com/Arvtesh/UnityFx.Async/releases)
Unity Asset Store | [![Asynchronous operations for Unity](https://img.shields.io/badge/tools-v0.8.2-green.svg)](https://assetstore.unity.com/packages/tools/asynchronous-operations-for-unity-96696)
Unity Asset Store | [![Asynchronous operations for Unity](https://img.shields.io/badge/tools-v0.9.1-green.svg)](https://assetstore.unity.com/packages/tools/asynchronous-operations-for-unity-96696)

## Synopsis

Expand Down Expand Up @@ -317,13 +317,13 @@ finally
### Cancellation
All library operations can be cancelled using `Cancel` method:
```csharp
op.Cancel();
op.Cancel();
```
Or with `WithCancellation` extension:
```csharp
DownloadTextAsync("http://www.google.com")
.Then(text => ExtractFirstParagraph(text))
.WithCancellation(cancellationToken);
```csharp
```
If the [token](https://docs.microsoft.com/en-us/dotnet/api/system.threading.cancellationtoken) passed to `WithCancellation` is cancelled the target operation is cancelled as well (and that means cancelling all chained operations) as soon as possible. Cancellation might not be instant (depends on specific operation implementation). Also, please note that not all operations might support cancellation; in this case `Cancel` will throw `NotSupportedException`.

Expand Down
2 changes: 1 addition & 1 deletion src/Build.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$scriptPath = split-path -parent $MyInvocation.MyCommand.Definition
$solutionPath = Join-Path $scriptPath "UnityFx.sln"
$solutionPath = Join-Path $scriptPath "UnityFx.Async.sln"
$configuration = $args[0]
$packagesPath = Join-Path $scriptPath "..\temp\BuildTools"
$binPath = Join-Path $scriptPath "..\bin"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Licensed under the MIT license. See the LICENSE.md file in the project root for more information.

using System;
#if NET_4_6
#if NET_4_6 || NET_STANDARD_2_0
using System.Threading.Tasks;
#endif

Expand All @@ -12,7 +12,7 @@ namespace UnityFx.Async.Samples
{
partial class LoadTextureHelper
{
#if NET_4_6
#if SHOULD_NEVER_GET_HERE //NET_4_6 || NET_STANDARD_2_0

/// <summary>
/// Waits for the <see cref="LoadTextureAsync(string)"/> in with <c>await</c>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static IAsyncOperation ToAsync(this AsyncOperation op)
{
var result = new AsyncCompletionSource(AsyncOperationStatus.Running, op);

#if UNITY_2017_2_OR_NEWER
#if UNITY_2017_2_OR_NEWER || UNITY_2018

// Starting with Unity 2017.2 there is AsyncOperation.completed event
op.completed += o => result.TrySetCompleted();
Expand Down Expand Up @@ -63,7 +63,7 @@ public static IAsyncOperation<T> ToAsync<T>(this ResourceRequest op) where T : U
{
var result = new AsyncCompletionSource<T>(AsyncOperationStatus.Running, op);

#if UNITY_2017_2_OR_NEWER
#if UNITY_2017_2_OR_NEWER || UNITY_2018

// Starting with Unity 2017.2 there is AsyncOperation.completed event
op.completed += o => result.TrySetResult(op.asset as T);
Expand Down Expand Up @@ -92,7 +92,7 @@ public static IAsyncOperation<T> ToAsync<T>(this AssetBundleRequest op) where T
{
var result = new AsyncCompletionSource<T>(AsyncOperationStatus.Running, op);

#if UNITY_2017_2_OR_NEWER
#if UNITY_2017_2_OR_NEWER || UNITY_2018

// Starting with Unity 2017.2 there is AsyncOperation.completed event
op.completed += o => result.TrySetResult(op.asset as T);
Expand All @@ -107,7 +107,7 @@ public static IAsyncOperation<T> ToAsync<T>(this AssetBundleRequest op) where T
}
}

#if NET_4_6 || NETFX_CORE
#if NET_4_6 || NET_STANDARD_2_0

/// <summary>
/// Provides an object that waits for the completion of an <see cref="AsyncOperation"/>. This type and its members are intended for compiler use only.
Expand Down Expand Up @@ -140,10 +140,10 @@ public void GetResult()
/// <inheritdoc/>
public void OnCompleted(Action continuation)
{
#if UNITY_2017_2_OR_NEWER
#if UNITY_2017_2_OR_NEWER || UNITY_2018

// Starting with Unity 2017.2 there is AsyncOperation.completed event
op.completed += o => continuation();
_op.completed += o => continuation();

#else

Expand Down Expand Up @@ -243,7 +243,7 @@ public static WebRequestResult<string> ToAsyncString(this UnityWebRequest reques
return WebRequestResult<string>.FromUnityWebRequest(request);
}

#if NET_4_6 || NETFX_CORE
#if NET_4_6 || NET_STANDARD_2_0

/// <summary>
/// Provides an object that waits for the completion of an <see cref="WWW"/>. This type and its members are intended for compiler use only.
Expand Down Expand Up @@ -369,7 +369,7 @@ public static WwwResult<string> ToAsyncString(this WWW request)
return WwwResult<string>.FromWWW(request);
}

#if NET_4_6 || NETFX_CORE
#if NET_4_6 || NET_STANDARD_2_0

/// <summary>
/// Provides an object that waits for the completion of an <see cref="WWW"/>. This type and its members are intended for compiler use only.
Expand Down
14 changes: 13 additions & 1 deletion src/UnityFx.Async.Tests/Tests/CompletionCallbackTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public async Task TryAddCompletionCallback_IsThreadSafe()
// Arrange
var op = new AsyncCompletionSource();
var counter = 0;
var d = new AsyncOperationCallback(CompletionCallback);

void CompletionCallback(IAsyncOperation o)
{
Expand All @@ -70,14 +71,25 @@ void TestMethod()
{
for (var i = 0; i < 10000; ++i)
{
op.TryAddCompletionCallback(CompletionCallback);
op.TryAddCompletionCallback(d);
}
}

void TestMethod2()
{
for (var i = 0; i < 10000; ++i)
{
op.RemoveCompletionCallback(d);
}
}

TestMethod();

// Act
await Task.WhenAll(
Task.Run(new Action(TestMethod)),
Task.Run(new Action(TestMethod)),
Task.Run(new Action(TestMethod2)),
Task.Run(new Action(TestMethod)));

// Assert
Expand Down
File renamed without changes.

0 comments on commit 6418115

Please sign in to comment.