// TODO: See if the check semantic is strict enough for most use case bool DoRead(StmObject[] isolateds, Action<object[]> tr) { object[] args = isolateds.Select((i) => i.Object.Value).ToArray(); tr(args); for (int i = 0; i < args.Length; i++) if (args[i] != isolateds[i].Object.Object) return false; return true; }
bool DoWrite(StmObject[] isolateds, Action<object[]> tr) { CloneContainer[] args = isolateds.Select((iso) => iso.GetClone()).ToArray(); object[] clones = new object[args.Length]; object[] initials = new object[args.Length]; int i = 0; foreach (CloneContainer cont in args) { clones[i] = cont.Clone; initials[i++] = cont.Initial; } tr(clones); return InterlockedEx.MultiCompareAndSwap(isolateds.Select((iso) => iso.Object).ToArray(), initials, clones); }
public void Setup () { b1 = new StmObject<BusinessClass>(new BusinessClass(1, "foo")); b2 = new StmObject<BusinessClass>(new BusinessClass(2, "bar")); }