Add cancellation support to game-side IResourceStores

This commit is contained in:
Bartłomiej Dach
2021-12-23 10:33:17 +01:00
parent 0732a9e6da
commit 1040590844
7 changed files with 16 additions and 8 deletions

View File

@ -3,6 +3,7 @@
using System.Collections.Generic;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using osu.Framework.IO.Stores;
@ -33,7 +34,7 @@ namespace osu.Game.IO.Archives
public virtual byte[] Get(string name) => GetAsync(name).Result;
public async Task<byte[]> GetAsync(string name)
public async Task<byte[]> GetAsync(string name, CancellationToken cancellationToken = default)
{
using (Stream input = GetStream(name))
{
@ -41,7 +42,7 @@ namespace osu.Game.IO.Archives
return null;
byte[] buffer = new byte[input.Length];
await input.ReadAsync(buffer).ConfigureAwait(false);
await input.ReadAsync(buffer, cancellationToken).ConfigureAwait(false);
return buffer;
}
}