internal static void SaveResultsAndClearLucenePool(string luceneIndex) { ReadWriteLock.TryEnterWriteLock(IndexConstants.ReadWriteLockTimeOutMilliseconds); try { if (IndexReaderPool.TryRemove(luceneIndex, out var indexReader)) { indexReader.Dispose(); } if (IndexWritesPool.TryRemove(luceneIndex, out var indexWriter)) { indexWriter.Dispose(); } IndexSearcherPool.TryRemove(luceneIndex, out _); IndexGotChanged.AddOrUpdate(luceneIndex, u => 0, (u, v) => 0); } finally { ReadWriteLock.ExitWriteLock(); } }
public void Dispose() { if (m_rwLock.IsValid) { if (m_isRead) { m_rwLock.ExitReadLock(); } else { m_rwLock.ExitWriteLock(); } } }
internal static void SaveResults(string luceneIndex, bool forceCommitChanges) { ReadWriteLock.TryEnterWriteLock(IndexConstants.ReadWriteLockTimeOutMilliseconds); try { if ((forceCommitChanges || shouldCommitChanges) && IndexWritesPool.TryGetValue(luceneIndex, out var indexWriter)) { indexWriter.Commit(); shouldCommitChanges = false; } } finally { ReadWriteLock.ExitWriteLock(); } }
public static IDisposable GetWriteLock(this ReadWriteLock readWriteLock) { readWriteLock.EnterWriteLock(); return(new DisposableAction(() => readWriteLock.ExitWriteLock())); }