import core.thread : Thread; immutable message = "The quick brown fox jumps over the lazy dog."; auto p = pipe(); void writer() { p.writeEnd.write(message); // Since this is buffered, it must be flushed in order to avoid a // deadlock. p.writeEnd.flush(); } auto thread = new Thread(&writer).start(); // Read the message from the other thread. char[message.length] buf; assert(buf[0 .. p.readEnd.read(buf)] == message); thread.join();
Creates an unnamed, unidirectional pipe that can be written to on one end and read from on the other.