Update Cached usage according to framework

This commit is contained in:
Thomas Müller
2017-07-02 13:00:02 +03:00
parent 2ba3c4b87a
commit 2d7eefa6fe
4 changed files with 21 additions and 12 deletions

View File

@ -81,13 +81,8 @@ namespace osu.Game.Rulesets.Timing
}
private Cached<double> durationBacking = new Cached<double>();
/// <summary>
/// The maximum duration of any one hit object inside this <see cref="DrawableTimingSection"/>. This is calculated as the maximum
/// end time between all hit objects relative to this <see cref="DrawableTimingSection"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// </summary>
public double Duration => durationBacking.EnsureValid()
? durationBacking.Value
: durationBacking.Refresh(() =>
private double computeDuration()
{
if (!Children.Any())
return 0;
@ -117,7 +112,13 @@ namespace osu.Game.Rulesets.Timing
baseDuration *= 1 + maxAbsoluteSize / ourAbsoluteSize;
return baseDuration;
});
}
/// <summary>
/// The maximum duration of any one hit object inside this <see cref="DrawableTimingSection"/>. This is calculated as the maximum
/// end time between all hit objects relative to this <see cref="DrawableTimingSection"/>'s <see cref="MultiplierControlPoint.StartTime"/>.
/// </summary>
public double Duration => durationBacking.IsValid ? durationBacking : (durationBacking.Value = computeDuration());
protected override void Update()
{