Example #1
0
		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);
		}
Example #2
0
		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);
		}
Example #3
0
		public State(TStateId stateId, IHId spacetimeId, IHEvent expectingEvent, StatePatchMethod patchMethod)
		{
			StateId = stateId;
			SpacetimeID = spacetimeId;
			LatestUpdate = expectingEvent;
			m_patchMethod = patchMethod;
			Rev = 0;
		}
Example #4
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;
			}
		}
Example #5
0
		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;
			}
		}
Example #6
0
		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);
			}
		}
Example #7
0
		internal void OnMigratingTo(IHId stid)
		{
			SpacetimeID = stid;
		}
Example #8
0
        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);
        }
Example #9
0
        public IHId CreateSiblingsOf(IHId elderBrother)
        {
			return CreateSiblingsOf(elderBrother, 1).First();
        }
Example #10
0
		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;
            }
		}
Example #11
0
		public TStateId? GetSpacetimeStorageSID(IHId stHid)
		{
			Spacetime st;
			if (!m_spaceTimes.TryGetValue(stHid, out st))
				return null;

			return st.StorageSID;
		}
Example #12
0
		public void PullFromVmSt(IHId spacetimeId)
		{
			m_spaceTimes[spacetimeId].PullFromVmSt(m_vmST.Snapshot(HTSFactory.CreateZeroEvent()), m_vmStateId);
		}
Example #13
0
		public bool PullRequest(IHId idPuller, IHId idRequester, IHEvent foreignExpectedEvent, ILookup<TStateId, StatePatch> affectedStates)
		{
			return m_spaceTimes[idPuller].PullRequest(idRequester, foreignExpectedEvent, affectedStates);
		}
Example #14
0
		public PrePullRequestResult PrePullRequest(IHId idPuller, IHId idRequester, IHEvent evtOriginal, IEnumerable<TStateId> affectedStates)
		{
			return m_spaceTimes[idPuller].PrePullRequest(idRequester, evtOriginal, affectedStates);
		}
Example #15
0
		public IHId CreateChild(IHId parent)
		{
			return CreateChildren(parent, 1).First();
		}
Example #16
0
		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);
		}
Example #17
0
		public static IHTimestamp Make(IHId id, IHEvent event_)
		{
			return new ITCTimestamp(id as ITCIdentity, event_ as ITCEvent);
		}