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)); }
private ITCIdentity(itc.Identity impl) { m_impl = impl; m_causalParent = this; }
internal ITCIdentity(itc.Identity impl, ITCIdentity causalParent) { m_impl = impl; m_causalParent = causalParent; }
private FreelistEntry CausallyExpand(ITCIdentity parent, uint batchSize) { return Expand(parent, parent, batchSize); }
private FreelistEntry ExpandSeed(ITCIdentity seed, uint batchSize) { return Expand(seed, seed.GetCausalParent(), batchSize); }
// 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}; }
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"); }
public ITCTimestamp(ITCIdentity id, ITCEvent event_) { m_IdCache = id; m_EventCache = event_; m_impl = new itc.TimeStamp(id.GetImpl(), event_.GetImpl()); }