Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
 public override void Teardown()
 {
     base.Teardown();
     if (ProtocolIdGenerator.IsQuorumProtocolIdentifier(ProtocolId))
     {
         Quorums[0].ReleaseId(ProtocolId);
     }
 }
Exemplo n.º 3
0
        public ulong GetNextProtocolId()
        {
            Debug.Assert(UsedIds.LongCount() < uint.MaxValue);
            while (UsedIds.Contains(WhichProtocol))
            {
                WhichProtocol++;
            }

            return(ProtocolIdGenerator.QuorumProtocolIdentifier(QuorumNumber, WhichProtocol++));
        }
Exemplo n.º 4
0
 public void ReleaseId(ulong id)
 {
     UsedIds.Remove(ProtocolIdGenerator.GetIntraQuorumProtocolNumber(id));
 }