Esempio n. 1
0
        public static void CreatePipe(long capacity, out Stream input, out Stream output)
        {
            using (DisposableStack insurance = new DisposableStack(3))
            {
                Flute  flute  = insurance.Add(new Flute(capacity));
                Stream writer = insurance.Add(flute.AcquireWriter(0, capacity));
                Stream reader = insurance.Add(flute.AcquireReader(0, capacity));

                DisposableStream disposableOutput = new DisposableStream(reader);
                disposableOutput.AfterDispose.Add(flute);
                disposableOutput.AfterDispose.Add(writer);

                input  = writer;
                output = disposableOutput;

                insurance.Clear();
            }
        }