Ruby IO#read 的 buffer 参数主要有什么用途?

FenRagwort · May 21, 2012 · Last by FenRagwort replied at May 21, 2012 · 3374 hits

IO 类的 read 实例方法有一种用法:read(length, buffer) 设置 buffer 主要有什么用途?什么情况下需要用到 buffer 呢?

顾名思义,buffer 就是缓存了。 如果你想对 IO 性能进行调整,就可以自己指定缓存大小。

#2 楼 @hooopo 多谢 Buffers are typically used when there is a difference between the rate at which data is received and the rate at which it can be processed, or in the case that these rates are variable, for example in a printer spooler or in online video streaming.

You need to Sign in before reply, if you don't have an account, please Sign up first.