コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: Soul.cs プロジェクト: ovuncgursoy/Lifetime
 /// <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()));
 }
コード例 #3
0
 /// <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());