Use Lazy for threadsafety on playfield

This commit is contained in:
smoogipoo 2017-12-14 20:27:51 +09:00
parent 6a690908cf
commit b28b86dea9
1 changed files with 3 additions and 2 deletions

View File

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