Ejemplo n.º 1
0
        internal IEnumerable<ITCIdentity> CreateChild(uint hintNum, ITCIdentity causalParent)
        {
            var num = BitOps.HighestBitPos(BitOps.RoundUp(hintNum - 1));

            var remains = new List<itc.Identity>();
            remains.Add(m_impl);
            for (var ii = 0; ii < num; ++ii)
            {
                var midresult = new List<itc.Identity>();
                foreach (var id in remains)
                {
                    var pair = id.Fork();
                    midresult.Add(pair.First);
                    midresult.Add(pair.Second);
                }
                remains = midresult;
            }

            return remains.Select((input) => new ITCIdentity(input, causalParent));
        }
Ejemplo n.º 2
0
		private ITCIdentity(itc.Identity impl)
		{
			m_impl = impl;
			m_causalParent = this;
		}
Ejemplo n.º 3
0
 internal ITCIdentity(itc.Identity impl, ITCIdentity causalParent)
 {
     m_impl = impl;
     m_causalParent = causalParent;
 }
Ejemplo n.º 4
0
 private FreelistEntry CausallyExpand(ITCIdentity parent, uint batchSize)
 {
     return Expand(parent, parent, batchSize);
 }
Ejemplo n.º 5
0
 private FreelistEntry ExpandSeed(ITCIdentity seed, uint batchSize)
 {
     return Expand(seed, seed.GetCausalParent(), batchSize);
 }
Ejemplo n.º 6
0
 // expand in the sibling tree style
 private FreelistEntry Expand(ITCIdentity parent, ITCIdentity causalParent, uint batchSize)
 {
         var all = parent.CreateChild(batchSize, causalParent).ToList();
         // preserve some nodes as seeds
         var seeds = all.GetRange(0,1);
         all.RemoveRange(0,1);
         return new FreelistEntry() {seeds = seeds, remains = all};
 }
Ejemplo n.º 7
0
        public ITCIdentityFactory(uint initialSize, uint batchSize)
        {
			m_batchSize = batchSize;

			m_root = ITCIdentity.CreateRootID();
            m_freelist = new ConcurrentDictionary<itc.Identity, FreelistEntry>();

            var entry = CausallyExpand(m_root, initialSize);
            entry.entryLock = new object();
            if (!m_freelist.TryAdd(m_root.GetImpl(), entry))
                throw new ApplicationException("ITCIdentityFactory being dereferenced while constructing");
        }
Ejemplo n.º 8
0
 public ITCTimestamp(ITCIdentity id, ITCEvent event_)
 {
     m_IdCache = id;
     m_EventCache = event_;
     m_impl = new itc.TimeStamp(id.GetImpl(), event_.GetImpl());
 }