public static CleaningCacheLock LockAndCleanCaches() { CleaningCacheLock result = new CleaningCacheLock(); try { Monitor.Enter(Guard, ref result.cacheIsLocked); result.saveAssembliesFromFiles = assembliesFromFiles; result.saveAssemblyKeys = assemblyKeys; result.saveModulesFromFiles = modulesFromFiles; result.saveModuleKeys = moduleKeys; result.saveAnalyzersFromFiles = analyzersFromFiles; result.saveAnalyzerAssemblyKeys = analyzerAssemblyKeys; var newAssembliesFromFiles = new Dictionary <FileKey, CachedAssembly>(); var newAssemblyKeys = new List <FileKey>(); var newModulesFromFiles = new Dictionary <FileKey, CachedModule>(); var newModuleKeys = new List <FileKey>(); var newAnalyzersFromFiles = new Dictionary <FileKey, CachedAnalyzers>(); var newAnalyzerAssemblyKeys = new List <FileKey>(); assembliesFromFiles = newAssembliesFromFiles; assemblyKeys = newAssemblyKeys; modulesFromFiles = newModulesFromFiles; moduleKeys = newModuleKeys; analyzersFromFiles = newAnalyzersFromFiles; analyzerAssemblyKeys = newAnalyzerAssemblyKeys; result.threadId = Thread.CurrentThread.ManagedThreadId; result.stackTrace = Environment.StackTrace; result.next = last; last = result; } catch { if (result.cacheIsLocked) { result.cacheIsLocked = false; Monitor.Exit(Guard); } throw; } return(result); }
public void Dispose() { if (cacheIsLocked) { assembliesFromFiles = this.saveAssembliesFromFiles; assemblyKeys = this.saveAssemblyKeys; modulesFromFiles = this.saveModulesFromFiles; moduleKeys = this.saveModuleKeys; System.Diagnostics.Debug.Assert(ReferenceEquals(last, this)); System.Diagnostics.Debug.Assert(this.threadId == Thread.CurrentThread.ManagedThreadId); last = this.next; cacheIsLocked = false; Monitor.Exit(Guard); } }
public void Dispose() { if (_cacheIsLocked) { DisposeCachedMetadata(); s_assembliesFromFiles = _saveAssembliesFromFiles; s_assemblyKeys = _saveAssemblyKeys; s_modulesFromFiles = _saveModulesFromFiles; s_moduleKeys = _saveModuleKeys; Debug.Assert(ReferenceEquals(s_last, this)); Debug.Assert(_threadId == Thread.CurrentThread.ManagedThreadId); s_last = _next; _cacheIsLocked = false; Monitor.Exit(Guard); } }
public void Dispose() { if (cacheIsLocked) { DisposeCachedMetadata(); assembliesFromFiles = this.saveAssembliesFromFiles; assemblyKeys = this.saveAssemblyKeys; modulesFromFiles = this.saveModulesFromFiles; moduleKeys = this.saveModuleKeys; analyzersFromFiles = this.saveAnalyzersFromFiles; analyzerAssemblyKeys = this.saveAnalyzerAssemblyKeys; Debug.Assert(ReferenceEquals(last, this)); Debug.Assert(this.threadId == Thread.CurrentThread.ManagedThreadId); last = this.next; cacheIsLocked = false; Monitor.Exit(Guard); } }
// for testing internal static CleaningCacheLock LockAndClean() { return(CleaningCacheLock.LockAndCleanCaches()); }
public void Dispose() { if (_cacheIsLocked) { DisposeCachedMetadata(); s_assembliesFromFiles = _saveAssembliesFromFiles; s_assemblyKeys = _saveAssemblyKeys; s_modulesFromFiles = _saveModulesFromFiles; s_moduleKeys = _saveModuleKeys; s_analyzersFromFiles = _saveAnalyzersFromFiles; s_analyzerAssemblyKeys = _saveAnalyzerAssemblyKeys; Debug.Assert(ReferenceEquals(s_last, this)); Debug.Assert(_threadId == Thread.CurrentThread.ManagedThreadId); s_last = _next; _cacheIsLocked = false; Monitor.Exit(Guard); } }
public static CleaningCacheLock LockAndCleanCaches() { CleaningCacheLock result = new CleaningCacheLock(); try { Monitor.Enter(Guard, ref result._cacheIsLocked); result._saveAssembliesFromFiles = s_assembliesFromFiles; result._saveAssemblyKeys = s_assemblyKeys; result._saveModulesFromFiles = s_modulesFromFiles; result._saveModuleKeys = s_moduleKeys; result._saveAnalyzersFromFiles = s_analyzersFromFiles; result._saveAnalyzerAssemblyKeys = s_analyzerAssemblyKeys; var newAssembliesFromFiles = new Dictionary<FileKey, CachedAssembly>(); var newAssemblyKeys = new List<FileKey>(); var newModulesFromFiles = new Dictionary<FileKey, CachedModule>(); var newModuleKeys = new List<FileKey>(); var newAnalyzersFromFiles = new Dictionary<FileKey, CachedAnalyzers>(); var newAnalyzerAssemblyKeys = new List<FileKey>(); s_assembliesFromFiles = newAssembliesFromFiles; s_assemblyKeys = newAssemblyKeys; s_modulesFromFiles = newModulesFromFiles; s_moduleKeys = newModuleKeys; s_analyzersFromFiles = newAnalyzersFromFiles; s_analyzerAssemblyKeys = newAnalyzerAssemblyKeys; result._threadId = Thread.CurrentThread.ManagedThreadId; result._stackTrace = Environment.StackTrace; result._next = s_last; s_last = result; } catch { if (result._cacheIsLocked) { result._cacheIsLocked = false; Monitor.Exit(Guard); } throw; } return result; }