/// <summary> /// Initialises a new instance with the specified cancellation token, progress-increment callback and optional output-stream-write batch-size configuration. Intended for use with asynchronous APIs. /// </summary> /// <param name="pCancellationToken">May be <see cref="CancellationToken.None"/>.</param> /// <param name="pIncrement">May be <see langword="null"/>.</param> /// <param name="pWrite">If <see langword="null"/> then <see cref="cIMAPClient.FetchBodyWriteConfiguration"/> will be used.</param> public cBodyFetchConfiguration(CancellationToken pCancellationToken, Action <int> pIncrement, cBatchSizerConfiguration pWrite = null) { Timeout = -1; CancellationToken = pCancellationToken; Increment = pIncrement; Write = pWrite; }
public void SetFetchBodyReadConfiguration(cBatchSizerConfiguration pConfiguration, cTrace.cContext pParentContext) { var lContext = pParentContext.NewMethod(nameof(cSession), nameof(SetFetchBodyReadConfiguration), pConfiguration); if (pConfiguration == null) { throw new ArgumentNullException(nameof(pConfiguration)); } mFetchBodyReadSizer = new cBatchSizer(pConfiguration); }
public cBatchSizer(cBatchSizerConfiguration pConfiguration) { Configuration = pConfiguration ?? throw new ArgumentNullException(nameof(pConfiguration)); mSamples[0] = new cSamples(1); mSamples[1] = new cSamples(5); mSamples[2] = new cSamples(10); mSamples[3] = new cSamples(50); Current = pConfiguration.Initial; mMaxTime = pConfiguration.MaxTime; }
/// <summary> /// Initialises a new instance with the specified timeout and optional output-stream-write batch-size configuration. Intended for use with synchronous APIs. /// </summary> /// <param name="pTimeout">May be <see cref="Timeout.Infinite"/>.</param> /// <param name="pWrite">If <see langword="null"/> then <see cref="cIMAPClient.FetchBodyWriteConfiguration"/> will be used.</param> public cBodyFetchConfiguration(int pTimeout, cBatchSizerConfiguration pWrite = null) { if (pTimeout < -1) { throw new ArgumentOutOfRangeException(nameof(pTimeout)); } Timeout = pTimeout; CancellationToken = CancellationToken.None; Increment = null; Write = pWrite; }
public cStreamCommandPart(Stream pStream, int pLength, bool pBinary, cBatchSizerConfiguration pReadConfiguration) : base(pBinary, false, false) { if (pStream == null) { throw new ArgumentNullException(nameof(pStream)); } if (pReadConfiguration == null) { throw new ArgumentNullException(nameof(pReadConfiguration)); } if (!pStream.CanRead) { throw new ArgumentOutOfRangeException(nameof(pStream)); } if (pLength < 0) { throw new ArgumentOutOfRangeException(nameof(pLength)); } Stream = pStream; mLength = pLength; ReadConfiguration = pReadConfiguration; }
public cCommandPipeline(cCallbackSynchroniser pSynchroniser, Action <cTrace.cContext> pDisconnected, cBatchSizerConfiguration pNetworkWriteConfiguration, cIdleConfiguration pIdleConfiguration, cTrace.cContext pParentContext) { var lContext = pParentContext.NewObject(nameof(cCommandPipeline), pIdleConfiguration); mSynchroniser = pSynchroniser ?? throw new ArgumentNullException(nameof(pSynchroniser)); mDisconnected = pDisconnected ?? throw new ArgumentNullException(nameof(pDisconnected)); if (pNetworkWriteConfiguration == null) { throw new ArgumentNullException(nameof(pNetworkWriteConfiguration)); } mConnection = new cConnection(pNetworkWriteConfiguration); mIdleConfiguration = pIdleConfiguration; mResponseTextProcessor = new cResponseTextProcessor(pSynchroniser); // these depend on the cancellationtokensource being constructed mBackgroundReleaser = new cReleaser("commandpipeline_background", mBackgroundCancellationTokenSource.Token); mBackgroundAwaiter = new cAwaiter(mBackgroundCancellationTokenSource.Token); mBackgroundSendBuffer = new cSendBuffer(pSynchroniser, mConnection, mBackgroundCancellationTokenSource.Token); // plumbing mIdleBlock.Released += mBackgroundReleaser.Release; // when the idle block is removed, kick the background process }
// (note for when adding more: they need to be disposed) public cSession(cCallbackSynchroniser pSynchroniser, fCapabilities pIgnoreCapabilities, fMailboxCacheDataItems pMailboxCacheDataItems, cBatchSizerConfiguration pNetworkWriteConfiguration, cIdleConfiguration pIdleConfiguration, cBatchSizerConfiguration pFetchCacheItemsConfiguration, cBatchSizerConfiguration pFetchBodyReadConfiguration, Encoding pEncoding, cTrace.cContext pParentContext) { var lContext = pParentContext.NewObject(nameof(cSession), pIgnoreCapabilities, pMailboxCacheDataItems, pNetworkWriteConfiguration, pIdleConfiguration, pFetchCacheItemsConfiguration, pFetchBodyReadConfiguration); mSynchroniser = pSynchroniser ?? throw new ArgumentNullException(nameof(pSynchroniser)); mIgnoreCapabilities = pIgnoreCapabilities; mMailboxCacheDataItems = pMailboxCacheDataItems; mPipeline = new cCommandPipeline(pSynchroniser, ZDisconnected, pNetworkWriteConfiguration, pIdleConfiguration, lContext); mFetchCacheItemsSizer = new cBatchSizer(pFetchCacheItemsConfiguration); mFetchBodyReadSizer = new cBatchSizer(pFetchBodyReadConfiguration); mCommandPartFactory = new cCommandPartFactory(false, null); if (pEncoding == null) { mEncodingPartFactory = mCommandPartFactory; } else { mEncodingPartFactory = new cCommandPartFactory(false, pEncoding); } }
public cConnection(cBatchSizerConfiguration pWriteConfiguration) { mWriteSizer = new cBatchSizer(pWriteConfiguration); }