public void UniqueIds(int pMaxParallel) { var map = new Dictionary <long, int>(); int count = 0; var opt = new ParallelOptions { MaxDegreeOfParallelism = pMaxParallel }; Parallel.For(0, 100000, opt, (i, state) => { long id = Sharpflake.GetId <Vertex>(); lock ( map ) { if (map.ContainsKey(id)) { Assert.Fail("Duplicate ID '" + id + "' at index '" + count + "'."); } map.Add(id, count); ++count; } }); /*foreach ( long id in map.Keys ) { * Log.Debug("ID: "+id+" / "+GetIdComponentString(id, true)+" / "+ * GetIdComponentString(id, false)); * }*/ }
/*--------------------------------------------------------------------------------------------*/ public override long GetSharpflakeId <T>() { lock (this) { long id = Sharpflake.GetId <T>(); SharpflakeIds.Add(id); return(id); } }
/*--------------------------------------------------------------------------------------------*/ public virtual long GetSharpflakeId <T>() where T : IVertex { return(Sharpflake.GetId <T>()); }