public ProjectFileLoaderRegistry(HostWorkspaceServices workspaceServices, DiagnosticReporter diagnosticReporter) { _workspaceServices = workspaceServices; _diagnosticReporter = diagnosticReporter; _extensionToLanguageMap = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); _dataGuard = new NonReentrantLock(); }
public SemanticChangeProcessor( IAsynchronousOperationListener listener, Registration registration, IncrementalAnalyzerProcessor documentWorkerProcessor, int backOffTimeSpanInMS, int projectBackOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { _gate = new SemaphoreSlim(initialCount: 0); _registration = registration; _processor = new ProjectProcessor(listener, registration, documentWorkerProcessor, projectBackOffTimeSpanInMS, cancellationToken); _workGate = new NonReentrantLock(); _pendingWork = new Dictionary <DocumentId, Data>(); Start(); // Register a clean-up task to ensure pending work items are flushed from the queue if they will // never be processed. AsyncProcessorTask.ContinueWith( _ => ClearQueueWorker(_workGate, _pendingWork, data => data.AsyncToken), CancellationToken.None, TaskContinuationOptions.ExecuteSynchronously, TaskScheduler.Default); }
private static void ClearQueueWorker <TKey, TValue>(NonReentrantLock gate, Dictionary <TKey, TValue> map, Func <TValue, IDisposable> disposerSelector) { using (gate.DisposableWait(CancellationToken.None)) { foreach (var(_, data) in map) { disposerSelector?.Invoke(data)?.Dispose(); } map.Clear(); } }
private static TValue DequeueWorker <TKey, TValue>(NonReentrantLock gate, Dictionary <TKey, TValue> map, CancellationToken cancellationToken) { using (gate.DisposableWait(cancellationToken)) { var first = default(KeyValuePair <TKey, TValue>); foreach (var kv in map) { first = kv; break; } // this is only one that removes data from the queue. so, it should always succeed var result = map.Remove(first.Key); Debug.Assert(result); return(first.Value); } }
public ProjectProcessor( IAsynchronousOperationListener listener, Registration registration, IncrementalAnalyzerProcessor processor, int backOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { _registration = registration; _processor = processor; _gate = new AsyncSemaphore(initialCount: 0); _workGate = new NonReentrantLock(); _pendingWork = new Dictionary <ProjectId, Data>(); Start(); }
public SemanticChangeProcessor( IAsynchronousOperationListener listener, Registration registration, IncrementalAnalyzerProcessor documentWorkerProcessor, int backOffTimeSpanInMS, int projectBackOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { _gate = new SemaphoreSlim(initialCount: 0); _registration = registration; _processor = new ProjectProcessor(listener, registration, documentWorkerProcessor, projectBackOffTimeSpanInMS, cancellationToken); _workGate = new NonReentrantLock(); _pendingWork = new Dictionary <DocumentId, Data>(); Start(); }
public ProjectProcessor( IAsynchronousOperationListener listener, int correlationId, Workspace workspace, IncrementalAnalyzerProcessor processor, int backOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { this.correlationId = correlationId; this.workspace = workspace; this.processor = processor; this.gate = new AsyncSemaphore(initialCount: 0); this.workGate = new NonReentrantLock(); this.pendingWork = new Dictionary <ProjectId, Data>(); Start(); }
public SemanticChangeProcessor( IAsynchronousOperationListener listener, int correlationId, Workspace workspace, IncrementalAnalyzerProcessor documentWorkerProcessor, int backOffTimeSpanInMS, int projectBackOffTimeSpanInMS, CancellationToken cancellationToken) : base(listener, backOffTimeSpanInMS, cancellationToken) { _gate = new AsyncSemaphore(initialCount: 0); _correlationId = correlationId; _workspace = workspace; _processor = new ProjectProcessor(listener, correlationId, workspace, documentWorkerProcessor, projectBackOffTimeSpanInMS, cancellationToken); _workGate = new NonReentrantLock(); _pendingWork = new Dictionary <DocumentId, Data>(); Start(); }
public SemaphoreDisposer(NonReentrantLock semaphore) { _semaphore = semaphore; }