internal bool Clean() { if (WriteMap != null) { WriteMap.Clean(); WriteMap = null; } return(true); /* * var toClean = Interlocked.Exchange(ref WriteMap, null); * // the toClean may be null because more * // than one thread may race into this method * // yet, because of the atomic getAndSet above, * // only one will actually clean the bodies * if (toClean != null) * { * toClean.Clean(); * return true; * } * else * { * return false; * }*/ }
public void Merge(WriteMap other) { foreach (var kvpair in other) { Add(kvpair.Key, kvpair.Value); } }
public WriteMap(WriteMap other) { foreach (var item in other) { Add(item.Key, item.Value); } }
private JVTransaction(TransactionStatus status, int id, JVTransaction parent, ReadMap readMap, WriteMap writeMap) { Number = id; Parent = parent; ReadMap = readMap; WriteMap = writeMap; Status = status; //Commutes = new List<BaseCommute>(); }
private JVTransaction(TransactionStatus status, ActiveTxnRecord txnRecord, JVTransaction parent, ReadMap readMap, WriteMap writeMap) { Number = txnRecord.TxNumber; Parent = parent; ReadMap = readMap; WriteMap = writeMap; Status = status; _txnRecord = txnRecord; //Commutes = new List<BaseCommute>(); }
public bool CommitLockFree() { if (WriteMap.Count == 0) { Status = TransactionStatus.Committed; TxnContext.LocalContext.OldestRequiredRecord = null; //_txnRecord.FinishTransaction(); return(true); } if (IsNested) { Parent.ReadMap.Merge(ReadMap); Parent.WriteMap.Merge(WriteMap); Status = TransactionStatus.Committed; return(true); } try { WriteMap.PrepareCommit(); ValidateCommitAndEnqueue(); EnsureCommitStatus(); Status = TransactionStatus.Committed; TxnContext.LocalContext.OldestRequiredRecord = null; //_txnRecord.FinishTransaction(); //Interlocked.Decrement(ref _commitTxnRecord.Running); return(true); } catch (STMCommitException) { return(false); } }
internal ActiveTxnRecord(int txNumber, WriteMap bodies) { TxNumber = txNumber; WriteMap = bodies; Running = 1; }