Пример #1
0
        public static CatkinId GenerateNewId(byte reserved = 0, long?timestamp = null, byte region = 0, ushort machine = 0, int?sequence = null)
        {
            long timestampLong = timestamp.HasValue ? timestamp.Value : CatkinIdTimer.GetMillisecondsSinceCatkinIdEpochFromDateTime(DateTime.UtcNow);

            int sequenceInt = -1;

            if (sequence.HasValue)
            {
                sequenceInt = sequence.Value;
            }
            else
            {
                int increment = Interlocked.Increment(ref __staticSequence);
                sequenceInt = increment & SequenceMask;
            }

            return(new CatkinId(reserved, timestampLong, region, machine, sequenceInt));
        }
Пример #2
0
        public static CatkinId GenerateNewId(byte reserved = 0, DateTime?timestamp = null, byte region = 0, ushort machine = 0, int?sequence = null)
        {
            long timestampLong = CatkinIdTimer.GetMillisecondsSinceCatkinIdEpochFromDateTime(timestamp.HasValue ? timestamp.Value : DateTime.UtcNow);

            return(GenerateNewId(reserved: reserved, timestamp: timestampLong, region: region, machine: machine, sequence: sequence));
        }