public ulong GetNextTwoProtocolId(Quorum other, bool incrementOther = true) { if (this == other) { return(GetNextProtocolId()); } if (!TwoQuorumProtocolIds.ContainsKey(other)) { TwoQuorumProtocolIds[other] = 0; } // if we are failing this assert, we need to expand the range Debug.Assert(TwoQuorumProtocolIds[other] <= ushort.MaxValue); ulong retId = ProtocolIdGenerator.TwoQuorumProtocolIdentifier(QuorumNumber, other.QuorumNumber, TwoQuorumProtocolIds[other]); TwoQuorumProtocolIds[other]++; // increment the id in the other quorum (necessary because a party may be part of both quorums) if (incrementOther) { other.GetNextTwoProtocolId(this, false); } return(retId); }
public override void Teardown() { base.Teardown(); if (ProtocolIdGenerator.IsQuorumProtocolIdentifier(ProtocolId)) { Quorums[0].ReleaseId(ProtocolId); } }
public ulong GetNextProtocolId() { Debug.Assert(UsedIds.LongCount() < uint.MaxValue); while (UsedIds.Contains(WhichProtocol)) { WhichProtocol++; } return(ProtocolIdGenerator.QuorumProtocolIdentifier(QuorumNumber, WhichProtocol++)); }
public void ReleaseId(ulong id) { UsedIds.Remove(ProtocolIdGenerator.GetIntraQuorumProtocolNumber(id)); }