コード例 #1
0
 internal BufferedStreamWriter(Stream stream, BufferedStreamWriterConfig config, IWriter writer)
 {
     this.stream        = stream;
     this.writer        = writer;
     shadowBufferSize   = config.ShadowBufferSize;
     currShadowBufferIx = 0;
     shadowBuffer       = writer.RequestBuffer();
 }
コード例 #2
0
 public DelayedWriter(Stream stream, BufferedStreamWriterConfig config)
 {
     this.stream       = stream;
     this.config       = config;
     flushBlockerEvent = new AsyncManualResetEvent(false);
     writeGatekeeper   = new SemaphoreSlim(config.TotalDelayedWriterBlocks);
     tokenSource       = new CancellationTokenSource();
     pendingOps        = new BlockingCollection <PendingOp>();
     availableBuffers  = new ConcurrentQueue <ShadowBufferData>();
     workerTask        = Task.Run(WorkerTaskEntrypoint);
 }
コード例 #3
0
 private static IWriter MakeWriter(Stream stream, BufferedStreamWriterConfig config)
 {
     if (config.UseDelayedWrite)
     {
         return(new DelayedWriter(stream, config));
     }
     else
     {
         return(new SynchronousWriter(stream, config));
     }
 }
コード例 #4
0
 public SynchronousWriter(Stream stream, BufferedStreamWriterConfig config)
 {
     this.stream  = stream;
     shadowBuffer = new ShadowBufferData(config.ShadowBufferSize);
 }
コード例 #5
0
 public BufferedStreamWriter(Stream stream, BufferedStreamWriterConfig config)
     : this(stream, config, MakeWriter(stream, config))
 {
 }