Dart:如何通过流将数据从一个进程传递到另一个进程 [英] Dart: How to pass data from one process to another via streams

查看:81
本文介绍了Dart:如何通过流将数据从一个进程传递到另一个进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要具有从dart启动两个进程,从第一个进程读取输入,在dart中操纵输出,然后将数据发送到第二个进程的能力.

I need the ability to start two processes from dart, read the input from the first process, manipulate the output in dart and then send the data to a second process.

注意:在此示例中,我声明了两个进程,但实际上,我可能需要创建一条涉及任意数量进程的管道.

Note: in this example I state two processes but in reality I may need to create a pipe line involving any number of processes.

这两个进程可能会长时间运行(假设数分钟),并且当这些进程处理数据时,输出必须可用(想想尾巴-f).

The two process are likely to be long running (assume minutes) and the output must be available as the processes process the data (think tail -f).

为了强调最后一点,该过程可能会输出大量数据,因此数据无法存储在内存中,因此是我尝试的流方法.

To re-inforce the last point the process may output large amounts of data so the data can't be stored in memory hence the stream approach that I've attempted.

我尝试了以下方法,但是我对流没有经验,所以我不确定自己是否走对了.

I've tried the following but I'm not experienced with streams so I'm not even certain if I'm on the right track.

https://dartpad.dev/3ad46c7e28c80f6735a9ee350091d509

推荐答案

您可以使用 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆