public void SolverNodeLookupByBucketWrap() { var collection = new SolverPoolSlimRwLock(new SolverPoolSimpleList()); foreach (var n in items) { if (collection.FindMatch(n) == null) { collection.Add(n); } } }
public void SolverNodeLookupByBucketWrap_Multi() { var collection = new SolverPoolSlimRwLock(new SolverPoolSimpleList()); var thread = Environment.ProcessorCount; var perThread = items.Length / thread; var tasks = Enumerable.Range(0, thread) .Select(x => Task.Run(() => { foreach (var n in items.Skip(x * perThread).Take(perThread)) { if (collection.FindMatch(n) == null) { collection.Add(n); } } })).ToArray(); Task.WaitAll(tasks); }