Exemple #1
0
        /// <summary>
        /// Initializes new instance of <see cref="StorageFileAppender"/> class.
        /// </summary>
        /// <param name="configuration">The configuration parameters for binary storage components</param>
        /// <param name="streamFactory"><see cref="IStreamFactory"/> object used to create file streams</param>
        /// <param name="binaryStorageIndex">reference to binary storage index structure</param>
        /// <exception cref="ArgumentNullException">factory is null</exception>
        /// <exception cref="IOException">storage file could not be opened</exception>
        public StorageFileAppender(StorageConfiguration configuration, IStreamFactory streamFactory, IBinaryStorageIndex binaryStorageIndex)
        {
            this.configuration      = configuration.ThrowIfNull(nameof(configuration));
            this.binaryStorageIndex = binaryStorageIndex.ThrowIfNull(nameof(binaryStorageIndex));
            this.streamFactory      = streamFactory.ThrowIfNull(nameof(streamFactory));

            buffer     = streamFactory.CreateStreamedIOBuffer();
            fileStream = streamFactory.CreateStorageAppendingStream();
            ShrinkStorageFile();

            pendingCounter   = 0;
            processedCounter = 0;
            waitingList      = new ConcurrentQueue <Tuple <long, ManualResetEvent> >();

            cancellationOnDispose = new CancellationTokenSource();
            processingThread      = new Thread(DoBufferProcessing);
            processingThread.Start();

            writeLock = new object();
        }
 /// <summary>
 /// Initializes new instance of <see cref="StreamFactory"/> class.
 /// </summary>
 /// <param name="configuration">The configuration parameters for binary storage components</param>
 /// <exception cref="System.ArgumentNullException">configuration is null, WorkingFolder is null</exception>
 public StreamFactory(StorageConfiguration configuration)
 {
     this.configuration = configuration.ThrowIfNull(nameof(configuration));
     configuration.WorkingFolder.ThrowIfNull(nameof(configuration.WorkingFolder));
 }