コード例 #1
0
ファイル: ByteWriter.cs プロジェクト: vladimir-shmidt/packer
 public Chunk Write(byte[] array, long index, long offset)
 {
     Logger.Log(Level.Verbose, $"writing {array.Length} bytes for chunk number {index} with {offset} bytes offset");
     try
     {
         Logger.Log(Level.Verbose, $"accruing semaphore for chunk number {index}");
         using (var map = _manager.BeginWrite())
         {
             Logger.Log(Level.Verbose, $"semaphore accrued write started");
             using (var accestor = map.CreateViewAccessor(offset, array.Length))
             {
                 accestor.WriteArray(0, array, 0, array.Length);
             }
             Logger.Log(Level.Verbose, "write finished");
             Array.Clear(array, 0, array.Length);
             return(new Chunk(array.Length, offset, index));
         }
     }
     finally
     {
         _manager.EndWrite();
         Logger.Log(Level.Debug, $"semaphore released for chunk number {index}");
     }
 }