/// <summary> /// /// </summary> /// <param name="sourctText"></param> /// <param name="replaceChar"></param> /// <returns></returns> public string Filter(string sourctText, char replaceChar) { root.WaitOne(); try { FilterWord f; _query.TryDequeue(out f); if (f == null) { f = new FilterWord(Path); f.IsPoolObject = true; f.PoolManager = this; } f.Reset(); f.SourctText = sourctText; var result = f.Filter(replaceChar); f.Dispose(); return(result); } catch (System.Exception ex) { Saker.SystemErrorProvide.OnSystemErrorHandleEvent(this, ex); return(""); } finally { root.Release(); } }
private void FreeObject(FilterWord filterWord) { if (filterWord == null) { return; } filterWord.IsPoolObject = false; filterWord.PoolManager = null; filterWord.Dispose(); }
internal void Push(FilterWord filterWord) { if (Interlocked.Read(ref _isDispose) != 0) { FreeObject(filterWord); return; } var q = _query; q?.Enqueue(filterWord); if (Interlocked.Read(ref _isDispose) != 0 && q != null) { while (!q.IsEmpty) { FilterWord f; if (!q.TryDequeue(out f)) { break; } FreeObject(f); } } }