I'm using a System.IO.Pipelines.Pipe in .NET 5 to transfer data from a stream to a reader, and now I'm thinking I'd like to have several independent readers that would all process same stream of data. Is there a variant of a Pipe that would let me have several equal readers?
Alternatively, if I do something like this, will pipe2 use the same segment (i.e. avoid needless copying of data)?
Memory<byte> memory = pipe1.Writer.GetMemory(10240);
int receivedBytesCount = await stream.ReadAsync(memory, token);
pipe1.Writer.Advance(receivedBytesCount);
await pipe2.Writer.WriteAsync(memory);
pipe2.Writer.Advance(receivedBytesCount);