gpt4 book ai didi

Node.js 流 : When will _writev Be Invoked?

转载 作者:行者123 更新时间:2023-12-04 08:15:46 24 4
gpt4 key购买 nike

Node.js 文档对 Writable 流的 _writev 做了以下评论。方法。

The writable._writev() method may be implemented in addition or alternatively to writable._write() in stream implementations that are capable of processing multiple chunks of data at once. If implemented and if there is buffered data from previous writes, _writev() will be called instead of _write().


强调我的。在什么情况下 Node.js 可写流可以缓冲先前写入的数据?
_writev方法只调用 after uncorking 已写入数据的软木塞流?或者是否还有其他场景可以让流从以前的写入中缓冲日期?如果您可以指出 Node.js 源代码中它做出决定是否调用 _write 的位置,那就加分了。或 _writev .

最佳答案

_writev()每当有多个数据从流中缓冲并且函数已定义时,将被调用。使用 cork()可能会导致缓冲更多数据,但 so could slow processing .
守卫的代码_writev is in lib/internal/streams/writable.js .有一个buffer decision然后 the guard for the write.

关于Node.js 流 : When will _writev Be Invoked?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65711452/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com