Esempio n. 1
0
        public static PeonyId GenerateNewId(byte reserved = 0, long?timestamp = null, byte region = 0, ushort machine = 0, int?sequence = null)
        {
            long timestampLong = timestamp.HasValue ? timestamp.Value : PeonyIdTimer.GetMillisecondsSincePeonyIdEpochFromDateTime(DateTime.UtcNow);

            int sequenceInt = -1;

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

            return(new PeonyId(reserved, timestampLong, region, machine, sequenceInt));
        }
Esempio n. 2
0
        public static PeonyId GenerateNewId(byte reserved = 0, DateTime?timestamp = null, byte region = 0, ushort machine = 0, int?sequence = null)
        {
            long timestampLong = PeonyIdTimer.GetMillisecondsSincePeonyIdEpochFromDateTime(timestamp.HasValue ? timestamp.Value : DateTime.UtcNow);

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