protected override async Task <bool> MoveNextInternal(CancellationToken cancel) { try { cancel.ThrowIfCancellationRequested(); if (triggerNext == null) { // no further trigger read operation pending (e.g. trigger sequence completed without producing a value) return(await source.MoveNext(cancel).ConfigureAwait(false)); } else { var sourceNext = source.MoveNext(cancel); await Task.WhenAny <bool>(triggerNext, sourceNext).ConfigureAwait(false); if (triggerNext.IsFaulted) { throw triggerNext.Exception; } if (sourceNext.IsFaulted) { throw sourceNext.Exception; } bool triggered = false; if (triggerNext.IsCompleted) { triggered = triggerNext.Result; triggerNext = null; trigger.Dispose(); } if (!triggered) { if (await sourceNext.ConfigureAwait(false)) { return(true); } } trigger.Dispose(); source.Dispose(); return(false); } } catch { trigger.Dispose(); source.Dispose(); throw; } }
public bool MaybePulseTransaction(IIterator before, int addToPulseCount = 1, Action beforePulseTransaction = null) { var increment = Interlocked.Add(ref maybePulseCount, addToPulseCount); if (increment < 1024) { return(false); } if (Interlocked.CompareExchange(ref maybePulseCount, 0, increment) != increment) { return(false); } if (writeBatch.Value.Size() >= PulseTreshold) { if (before != null) { before.Dispose(); } if (beforePulseTransaction != null) { beforePulseTransaction(); } logger.Debug("MaybePulseTransaction() --> PulseTransaction()"); PulseTransaction(); return(true); } return(false); }
public void RemoveIterator() { if (m_IterationContext != null) { m_IterationContext.Dispose(); m_IterationContext = null; } }
public void StepOut() { int newState; switch (_currentState) { default: throw new InvalidOperationException("current value is not in a container"); case S_IN_STRUCT: case S_NAME: case S_VERSION: case S_MAX_ID: case S_IMPORT_LIST: case S_AFTER_IMPORT_LIST: case S_SYMBOL_LIST: case S_STRUCT_CLOSE: // these are all top level so stepOut() ends up at the end of our data newState = S_EOF; break; case S_IN_IMPORTS: case S_IMPORT_STRUCT: case S_IMPORT_LIST_CLOSE: // if we're outside a struct, and we're in the import list stepOut will be whatever follows the import list // close and we're done with these _currentImportTable = null; _importTablesIterator.Dispose(); newState = StateFollowingImportList(Op.StepOut); break; case S_IN_IMPORT_STRUCT: case S_IMPORT_NAME: case S_IMPORT_VERSION: case S_IMPORT_MAX_ID: case S_IMPORT_STRUCT_CLOSE: // if there is a next import the next state will be its struct open // otherwise next will be the list close newState = _importTablesIterator.HasNext() ? S_IMPORT_STRUCT : S_IMPORT_LIST_CLOSE; break; case S_IN_SYMBOLS: case S_SYMBOL: case S_SYMBOL_LIST_CLOSE: // I think this is just S_EOF, but if we ever put anything after the symbol list this // will need to be updated. And we're done with our local symbol references. _stringValue = null; _localSymbolsIterator.Dispose(); newState = StateFollowingLocalSymbols(); break; } _currentState = newState; }
public bool MaybePulseTransaction(IIterator before) { if (Interlocked.Increment(ref maybePulseCount) % 1000 != 0) { return(false); } if (writeBatch.Value.Size() >= PulseTreshold) { if (before != null) { before.Dispose(); } PulseTransaction(); return(true); } return(false); }
public void Dispose() { iterator.Dispose(); }
public void Dispose() { first.Dispose(); second.Dispose(); }
public bool MaybePulseTransaction(IIterator before) { if (Interlocked.Increment(ref maybePulseCount)%1000 != 0) return false; if (writeBatch.Value.Size() >= PulseTreshold) { if (before != null) before.Dispose(); PulseTransaction(); return true; } return false; }
public void Dispose() { _importTablesIterator?.Dispose(); _localSymbolsIterator?.Dispose(); }
public bool MaybePulseTransaction(IIterator before, int addToPulseCount = 1, Action beforePulseTransaction = null) { var increment = Interlocked.Add(ref maybePulseCount, addToPulseCount); if (increment < 1024) { return false; } if (Interlocked.CompareExchange(ref maybePulseCount, 0, increment) != increment) { return false; } if (writeBatch.Value.Size() >= PulseTreshold) { if (before != null) before.Dispose(); if (beforePulseTransaction != null) beforePulseTransaction(); logger.Debug("MaybePulseTransaction() --> PulseTransaction()"); PulseTransaction(); return true; } return false; }
public void Dispose() { TR.Enter(); iterator.Dispose(); TR.Exit(); }