public T Dequeue() { return(ReaderWriterLock.ExecuteInWriterLock(() => { if (IsEmptyIntern()) { throw new InvalidOperationException("empty queue"); } foreach (var q in _data.Values) { if (q.Count > 0) { _count--; return q.Dequeue(); } } throw new Exception("corrupt data"); })); }
public int GetPrio(SearchJob job) { if (LinkChecker.ImpressumChecker.IsRelevant(job.Link)) { return(1); // top prio } var url = job.Link.Uri; var host = url.Host; var depth = job.CurrentDepth; var maxDepth = job.MaxDepth; var isDeDomain = host.EndsWith(".de"); if (!isDeDomain) { return(500000); } double factor = (maxDepth + 1.0) / (depth + 1.0); return(_readerWriterLock.ExecuteInUpgradeableReaderLock(() => { if (_visitedHosts.Contains(host)) { return (int)Math.Ceiling(100 * factor); } else { return _readerWriterLock.ExecuteInWriterLock(() => { _visitedHosts.Add(host); return (int)Math.Ceiling(10 * factor); }); } })); }