github.com/nevalang/neva@v0.23.1-0.20240507185603-7696a9bb8dda/std/builtin/streams.neva (about) 1 // StreamPort iterates over all array-inport's slots in order 2 // and produces a stream of messages. 3 #extern(array_port_to_stream) 4 pub component StreamPort<T>([port] T) (seq stream<T>) 5 6 // IPortReducer reduces a stream of messages to one single message. 7 // It's expected to send a result message after every processed stream. 8 pub interface IPortReducer<T>(seq stream<T>) (res T) 9 10 // ReducePort reduces messages from multiple connections to a single message. 11 // It iterates over all array-inport's slots in order and streams every message 12 // to reducer. When all messages are processed the result is emited to outport. 13 pub component ReducePort<T>([port] T) (res T) { 14 nodes { reducer IPortReducer<T>, streamer StreamPort<T> } 15 :port => streamer:port 16 streamer -> reducer -> :res 17 }