NodeJS文档提到了流动/非流动模式(在ReadableState
中)。以下摘录进一步解释了可读流可以一次进入的不同可能状态。 (https://nodejs.org/api/stream.html#stream_three_states)
Specifically, at any given point in time, every Readable is in one of three possible states:
readable._readableState.flowing = null
readable._readableState.flowing = false
readable._readableState.flowing = true
我很感激任何提供更多解释的参考资料。我特别好奇每个州的特征/行为;什么行动会触发不同国家之间的过渡?此外。
如果我没有错,在流动模式下:流在非流动模式下主动生成数据:在调用r.read(size)
之前,流不会生成任何数据。
非流动模式和暂停模式之间有什么区别吗? r.isPaused()
时_readableState.flowing == null
为假。
答案 0 :(得分:1)
最好的选择可能是在github上搜索源/回购以获得“流动”#。
可读流有效地以两种模式之一运行:流动和 暂停。在流动模式下,从中读取数据 底层系统自动提供给应用程序 尽可能快地通过......明确地使用事件来阅读 来自流的数据块。所有[可读] []流 在暂停模式下开始,但可以切换到流动
https://github.com/nodejs/node/search?q=flowing&type=Code&utf8=%E2%9C%93