// Since this release transmitting ports is possible. This means that we can // send ports through ports. In fact, we can send ports that may send ports that // may send ports. But don't be fooled by the apparent complexity. The inner // type `T` of a port like `in` simply states that that is the message type. // Should the type `T` contain one or more ports, then we kick off a bit of code // that takes care of the transfer of the port. Should the port inside of `T` // itself, after being received, send a port, then we simply kick off that same // procedure again. // // In the simplest case, we have someone transmitting the receiving end of a // channel to another component, which then uses that receiving end to receive a // value. comp port_sender(out> tx, in to_transmit) { sync put(tx, to_transmit); } comp port_receiver_and_value_getter(in> rx, u32 expected_value) { u32 got_value = 0; sync { auto port = get(rx); got_value = get(port); } if (expected_value == got_value) { print("got the expected value :)"); } else { print("got a different value :("); } } comp value_sender(out tx, u32 to_send) { sync put(tx, to_send); } comp main() { u32 value = 1337_2392; channel port_tx -> port_rx; channel value_tx -> value_rx; new port_sender(port_tx, value_rx); new port_receiver_and_value_getter(port_rx, value); new value_sender(value_tx, value); }