Use Lazy for threadsafety on playfield

This commit is contained in:
smoogipoo 2017-12-14 20:27:51 +09:00
parent 6a690908cf
commit b28b86dea9

View File

@ -55,11 +55,11 @@ namespace osu.Game.Rulesets.UI
public abstract IEnumerable<HitObject> Objects { get; } public abstract IEnumerable<HitObject> Objects { get; }
private Playfield playfield; private readonly Lazy<Playfield> playfield;
/// <summary> /// <summary>
/// The playfield. /// The playfield.
/// </summary> /// </summary>
public Playfield Playfield => playfield ?? (playfield = CreatePlayfield()); public Playfield Playfield => playfield.Value;
protected readonly Ruleset Ruleset; protected readonly Ruleset Ruleset;
@ -70,6 +70,7 @@ namespace osu.Game.Rulesets.UI
protected RulesetContainer(Ruleset ruleset) protected RulesetContainer(Ruleset ruleset)
{ {
Ruleset = ruleset; Ruleset = ruleset;
playfield = new Lazy<Playfield>(CreatePlayfield);
} }
public abstract ScoreProcessor CreateScoreProcessor(); public abstract ScoreProcessor CreateScoreProcessor();