Function holdingValve

Create a valve that uses a holding location to pass data from the inlet to the outlet.

auto auto holdingValve(Chain) (
  Chain chain
if (isIopipe!Chain);

A holding valve allows one to manually control when data is released downstream. The holding valve consists of 3 parts: - An input buffer, controlled by an iopipe called the inlet. This gives access to the input parameter chain. - A holding area for data that has been released by the inlet to the outlet. This is basically a FIFO queue. - An output buffer, controlled by an iopipe called the outlet. This is the tail end of the holding valve, and provides data downstream.

The inlet is a bit different than the normal iopipe, because it doesn't release data upstream, but rather downstream into the holding area.

The outlet, when releasing data goes upstream with the release call, giving the data back to the buffered source.

One major purpose of the holding valve is to use an autoValve to automate the downstream section, and let the user code interact directly with the inlet.

For example, this creates effectively an output stream:

import std.format;

auto stream = bufferedSource!(char).holdingValve.outputFile("out.txt").autoValve;
stream.extend(100); // create a buffer of 100 characters (at least)

void outputRange(const(char)[] str)
   if(stream.window.length < str.length)
      stream.extend(0); // extend as needed
   stream.window[0 .. str.length] = str;
foreach(i; 0 .. 100)


chain The upstream iopipe to which the valve controls access.


A valve assembly that gives access to the outlet via the return iopipe, and access to the inlet via the valve member.