Пример #1
0
        /// <summary>
        ///     Initializes this generator for the given endpoint type.
        /// </summary>
        /// <param name="type"></param>
        public GrainIdGenerator(EndPointType type)
        {
            const ulong midPoint = (MaxValue - MinValue) / 2 + MinValue;

            switch (type)
            {
            case EndPointType.Client:
                _range = new GrainIdRange(MinValue, midPoint - 1);
                break;

            case EndPointType.Server:
                _range = new GrainIdRange(midPoint, MaxValue);
                break;

            default:
                throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(EndPointType));
            }

            _nextId = _range.Minimum;
        }
Пример #2
0
 static GrainIdGenerator()
 {
     TotalReservedRange = new GrainIdRange(MinValue, MaxValue);
 }
Пример #3
0
 /// <summary>
 ///     Initializes this generator for the given endpoint type.
 /// </summary>
 /// <param name="type"></param>
 public GrainIdGenerator(EndPointType type)
 {
     _range  = GetRangeFor(type);
     _nextId = _range.Minimum;
 }