/// <summary> /// Constructor used for cloning /// </summary> /// <param name="cloneInput"></param> public SyncIndexInput(SyncIndexInput cloneInput) { _name = cloneInput._name; _syncDirectory = cloneInput._syncDirectory; if (string.IsNullOrWhiteSpace(_name)) { throw new ArgumentNullException(nameof(cloneInput._name)); } if (_syncDirectory == null) { throw new ArgumentNullException(nameof(cloneInput._syncDirectory)); } _fileMutex = SyncMutexManager.GrabMutex(cloneInput._syncDirectory, cloneInput._name); _fileMutex.WaitOne(); try { #if FULLDEBUG Trace.WriteLine($"Creating clone for {cloneInput._name}"); #endif _cacheDirIndexInput = (IndexInput)cloneInput._cacheDirIndexInput.Clone(); } catch (Exception) { // sometimes we get access denied on the 2nd stream...but not always. I haven't tracked it down yet // but this covers our tail until I do Trace.TraceError($"Dagnabbit, falling back to memory clone for {cloneInput._name}"); } finally { _fileMutex.ReleaseMutex(); } }
public override object Clone() { IndexInput clone = null; try { _fileMutex.WaitOne(); var input = new SyncIndexInput(this); clone = input; } catch (Exception err) { Trace.TraceError(err.ToString()); } finally { _fileMutex.ReleaseMutex(); } Debug.Assert(clone != null); return(clone); }
public SyncIndexInput(SyncIndexInput cloneInput) { _fileMutex = SyncMutexManager.GrabMutex(cloneInput._syncDirectory, cloneInput._name); _fileMutex.WaitOne(); try { #if FULLDEBUG Debug.WriteLine($"Creating clone for {cloneInput._name}"); #endif _syncDirectory = cloneInput._syncDirectory; _indexInput = cloneInput._indexInput.Clone() as IndexInput; } catch (Exception) { // sometimes we get access denied on the 2nd stream...but not always. I haven't tracked it down yet // but this covers our tail until I do Trace.Fail($"Dagnabbit, falling back to memory clone for {cloneInput._name}"); } finally { _fileMutex.ReleaseMutex(); } }
/// <summary> /// Constructor used for cloning /// </summary> /// <param name="cloneInput"></param> public SyncIndexInput(SyncIndexInput cloneInput) : this(cloneInput, new TraceLoggingService()) { }