Beispiel #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);
     }
 }
Beispiel #2
0
        public void SetTVarHandleData(TVarId tvarId, Object data)
        {
            var handle = new TVarHandle();

            handle.data              = data;
            handle.ustamp            = this.stagedTVars[tvarId].ustamp;
            handle.modified          = true;
            this.stagedTVars[tvarId] = handle;
        }
Beispiel #3
0
        public void AddTVarHandle(TVarId tvarId, TVarHandle tvarHandle)
        {
            var isFound = this.stagedTVars.TryGetValue(tvarId, out var found);

            if (isFound)
            {
                throw new Exception("TVar is not unique!");
            }
            this.stagedTVars[tvarId] = tvarHandle;
        }