Merge pull request #20691 from JamesNK/jamesnk/bufferwriter-length

Provide length when getting serialization buffer writer
pull/20736/head
Jan Tattermusch 6 years ago committed by GitHub
commit 3e48b2073f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 13
      src/csharp/Grpc.Core.Api/SerializationContext.cs
  2. 5
      src/csharp/Grpc.Core/Internal/DefaultSerializationContext.cs

@ -46,13 +46,24 @@ namespace Grpc.Core
throw new NotImplementedException();
}
/// <summary>
/// Sets the payload length when writing serialized data into a buffer writer. If the serializer knows the full payload
/// length in advance, providing that information before obtaining the buffer writer using <c>GetBufferWriter()</c> can improve
/// serialization efficiency by avoiding copies. The provided payload length must be the same as the data written to the writer.
/// Calling this method is optional. If the payload length is not set then the length is calculated using the data written to
/// the buffer writer when <c>Complete()</c> is called.
/// </summary>
/// <param name="payloadLength">The total length of the payload in bytes.</param>
public virtual void SetPayloadLength(int payloadLength)
{
}
/// <summary>
/// Complete the payload written to the buffer writer. <c>Complete()</c> can only be called once.
/// </summary>
public virtual void Complete()
{
throw new NotImplementedException();
}
}
}

@ -56,6 +56,11 @@ namespace Grpc.Core.Internal
return sliceBuffer;
}
public override void SetPayloadLength(int payloadLength)
{
// Length is calculated using the buffer writer
}
/// <summary>
/// Complete the payload written so far.
/// </summary>

Loading…
Cancel
Save