Use nullable cancellation tokens

This commit is contained in:
smoogipoo 2019-05-10 17:42:45 +09:00
parent 3860282ace
commit ad4b4f3422
3 changed files with 8 additions and 13 deletions

View File

@ -141,7 +141,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
public virtual PlayfieldAdjustmentContainer CreatePlayfieldAdjustmentContainer() => new PlayfieldAdjustmentContainer();
[BackgroundDependencyLoader]
private void load(OsuConfigManager config, CancellationToken cancellationToken)
private void load(OsuConfigManager config, CancellationToken? cancellationToken)
{
InternalChildren = new Drawable[]
{
@ -170,18 +170,15 @@ private void load(OsuConfigManager config, CancellationToken cancellationToken)
/// <summary>
/// Creates and adds drawable representations of hit objects to the play field.
/// </summary>
private void loadObjects(CancellationToken cancellationToken)
private void loadObjects(CancellationToken? cancellationToken)
{
foreach (TObject h in Beatmap.HitObjects)
{
if (cancellationToken.IsCancellationRequested)
break;
cancellationToken?.ThrowIfCancellationRequested();
addHitObject(h);
}
if (cancellationToken.IsCancellationRequested)
return;
cancellationToken?.ThrowIfCancellationRequested();
Playfield.PostProcess();

View File

@ -58,7 +58,7 @@ public DrawableStoryboard(Storyboard storyboard)
}
[BackgroundDependencyLoader(true)]
private void load(FileStore fileStore, GameplayClock clock, CancellationToken cancellationToken)
private void load(FileStore fileStore, GameplayClock clock, CancellationToken? cancellationToken)
{
if (clock != null)
Clock = clock;
@ -67,8 +67,7 @@ private void load(FileStore fileStore, GameplayClock clock, CancellationToken ca
foreach (var layer in Storyboard.Layers)
{
if (cancellationToken.IsCancellationRequested)
break;
cancellationToken?.ThrowIfCancellationRequested();
Add(layer.CreateDrawable());
}

View File

@ -25,12 +25,11 @@ public DrawableStoryboardLayer(StoryboardLayer layer)
}
[BackgroundDependencyLoader]
private void load(CancellationToken cancellationToken)
private void load(CancellationToken? cancellationToken)
{
foreach (var element in Layer.Elements)
{
if (cancellationToken.IsCancellationRequested)
break;
cancellationToken?.ThrowIfCancellationRequested();
if (element.IsDrawable)
AddInternal(element.CreateDrawable());