public static IComparer<IHEvent> GetEventComparer(IHId mask) { if (!typeof(ITCIdentity).IsAssignableFrom(mask.GetType())) throw new ArgumentException("provided hid is not implemented in the same implementation family"); return new ITCEventComparer((ITCIdentity)mask); }
public VMSpacetime(IHId hid, IHIdFactory idFactory) : base(hid, HTSFactory.CreateZeroEvent(), idFactory) { VMStateId = m_vm.StateId; m_storageComponent.AddNativeState(m_vm); ServiceManager.LocatingService.RegisterObject(VMStateId, m_vm.GetType().FullName, m_vm); }
public State(TStateId stateId, IHId spacetimeId, IHEvent expectingEvent, StatePatchMethod patchMethod) { StateId = stateId; SpacetimeID = spacetimeId; LatestUpdate = expectingEvent; m_patchMethod = patchMethod; Rev = 0; }
public void UpdateLocalStorage(IHId hid, IHEvent event_) { var meta = m_localStorages[hid]; meta.LatestUpdate = event_; foreach (var state in meta.Storage.GetNativeStates()) { m_localStates[state.StateId] = hid; } }
public SpacetimeSnapshot? GetSpacetime(IHId id, IHEvent evtAck) { lock (m_lock) { Spacetime st; if (m_spaceTimes.TryGetValue(id, out st)) return st.Snapshot(evtAck); return null; } }
public ComputeNode(int n, int upperbound, DeployMode deployMode) { m_nodeSerial = n; if (deployMode == DeployMode.Debug || deployMode == DeployMode.UnitTest) HIdFactory = new ITCIdentityFactory(4, 4); else HIdFactory = new ITCIdentityFactory(); // TODO: merge-able ITC m_nodeRoot = HIdFactory.CreateFromRoot(upperbound).ElementAt(n); if (m_nodeSerial == 0) { m_vmstStandalone = new VMSpacetime(CreateHid(), HIdFactory); } }
internal void OnMigratingTo(IHId stid) { SpacetimeID = stid; }
public IEnumerable<IHId> CreateSiblingsOf(IHId elderBrother, int count) { ITCIdentity itcEB = elderBrother as ITCIdentity; if (itcEB == null) throw new ArgumentException("The source Id was not from this factory"); var itcParent = itcEB.GetCausalParent(); return CreateChildren(itcParent, count); }
public IHId CreateSiblingsOf(IHId elderBrother) { return CreateSiblingsOf(elderBrother, 1).First(); }
public IEnumerable<IHId> CreateChildren(IHId parent, int count) { var itcParent = parent as ITCIdentity; if (itcParent == null) throw new ArgumentException("The source Id was not from this factory"); uint batchSize = Math.Max(BitOps.RoundUp((uint)count), m_batchSize); var entry = m_freelist.GetOrAdd(itcParent.GetImpl(), (_) => { var newEntry = CausallyExpand(itcParent, batchSize); newEntry.entryLock = new object(); return newEntry; }); lock (entry.entryLock) { if (entry.remains.Count <= count) // plant a seed { var seeds = entry.seeds; var seed = seeds[seeds.Count - 1]; seeds.RemoveAt(seeds.Count - 1); var expandRet = ExpandSeed(seed, batchSize); entry.remains.AddRange(expandRet.remains); entry.seeds.AddRange(expandRet.seeds); } // consume a free node var retval = entry.remains.GetRange(0, count); entry.remains.RemoveRange(0, count); return retval; } }
public TStateId? GetSpacetimeStorageSID(IHId stHid) { Spacetime st; if (!m_spaceTimes.TryGetValue(stHid, out st)) return null; return st.StorageSID; }
public void PullFromVmSt(IHId spacetimeId) { m_spaceTimes[spacetimeId].PullFromVmSt(m_vmST.Snapshot(HTSFactory.CreateZeroEvent()), m_vmStateId); }
public bool PullRequest(IHId idPuller, IHId idRequester, IHEvent foreignExpectedEvent, ILookup<TStateId, StatePatch> affectedStates) { return m_spaceTimes[idPuller].PullRequest(idRequester, foreignExpectedEvent, affectedStates); }
public PrePullRequestResult PrePullRequest(IHId idPuller, IHId idRequester, IHEvent evtOriginal, IEnumerable<TStateId> affectedStates) { return m_spaceTimes[idPuller].PrePullRequest(idRequester, evtOriginal, affectedStates); }
public IHId CreateChild(IHId parent) { return CreateChildren(parent, 1).First(); }
void RemoveSpacetime(IHId spacetimeId) { ExternalSTEntry entry; if (!m_externalSTs.TryGetValue(spacetimeId, out entry)) return; foreach (var sid in entry.LocalStates.Keys) if (!m_nativeStates.ContainsKey(sid)) m_stateCache.Remove(sid); m_externalSTs.Remove(spacetimeId); }
public static IHTimestamp Make(IHId id, IHEvent event_) { return new ITCTimestamp(id as ITCIdentity, event_ as ITCEvent); }