コード例 #1
0
 public bool TryCommit(UStamp ustamp, TVars stagedTvars)
 {
     lock (_lockObj)
     {
         bool conflict = false;
         foreach (var it in stagedTvars)
         {
             TVarId stagedTVarId = it.Key;
             var    isFound      = _tvars.TryGetValue(stagedTVarId, out var found);
             if (!isFound)
             {
                 continue;
             }
             if (it.Value.modified && (it.Value.ustamp != found.ustamp))
             {
                 conflict = true;
                 break;
             }
         }
         if (!conflict)
         {
             foreach (var it in stagedTvars)
             {
                 var handle = new TVarHandle();
                 handle.data     = it.Value.data;
                 handle.ustamp   = it.Value.ustamp;
                 handle.modified = it.Value.modified;
                 _tvars[it.Key]  = handle;
             }
         }
         return(!conflict);
     }
 }
コード例 #2
0
 public AtomicRuntime(Context context, UStamp ustamp, TVars tvars)
 {
     this.context     = context;
     this.ustamp      = ustamp;
     this.stagedTVars = tvars;
 }