예제 #1
0
        public static JasmineId GenerateNewId(byte reserved = 0, long?timestamp = null, byte region = 0, ushort machine = 0, int?sequence = null)
        {
            long timestampLong = timestamp.HasValue ? timestamp.Value : JasmineIdTimer.GetSecondsSinceJasmineIdEpochFromDateTime(DateTime.UtcNow);

            int sequenceInt = -1;

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

            return(new JasmineId(reserved, timestampLong, region, machine, sequenceInt));
        }
예제 #2
0
        public static JasmineId GenerateNewId(byte reserved = 0, DateTime?timestamp = null, byte region = 0, ushort machine = 0, int?sequence = null)
        {
            long timestampLong = JasmineIdTimer.GetSecondsSinceJasmineIdEpochFromDateTime(timestamp.HasValue ? timestamp.Value : DateTime.UtcNow);

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