private Phase TryOptimize() { var phase = _subSoul.Phase; if (_collapsed) { return(phase); // already optimized } if (phase == Phase.Mortal) { return(phase); // can't optimize yet } // the following is idempotent, so it's fine if multiple writers race _collapsed = true; _subSoul = Phase.AsPermanentSoul(); return(phase); }
/// <summary> /// Returns a lifetime permanently stuck in the given phase. /// A permanently mortal soul is considered to be immortal. /// </summary> public static Lifetime AsPermanentLifetime(this Phase phase) { return(new Lifetime(phase.AsPermanentSoul())); }
/// <summary> /// Returns a lifetime permanently stuck in the given phase. /// A permanently mortal soul is considered to be immortal. /// </summary> public static Lifetime AsPermanentLifetime(this Phase phase) => new Lifetime(phase.AsPermanentSoul());