1 回答

TA貢獻1848條經驗 獲得超6個贊
它不在 Go 源代碼中,因為它依賴于操作系統。
應用程序不應依賴于特定的容量:應用程序應設計為讀取進程在數據可用時立即使用數據,這樣寫入進程就不會一直處于阻塞狀態。
例如,在 Linux 上:
$ man pipe
PIPE(2) Linux Programmer's Manual PIPE(2)
NAME
pipe, pipe2 - create pipe
Pipe capacity
A pipe has a limited capacity. If the pipe is full, then a write(2)
will block or fail, depending on whether the O_NONBLOCK flag is set
(see below). Different implementations have different limits for the
pipe capacity. Applications should not rely on a particular
capacity: an application should be designed so that a reading process
consumes data as soon as it is available, so that a writing process
does not remain blocked.
In Linux versions before 2.6.11, the capacity of a pipe was the same
as the system page size (e.g., 4096 bytes on i386). Since Linux
2.6.11, the pipe capacity is 16 pages (i.e., 65,536 bytes in a system
with a page size of 4096 bytes). Since Linux 2.6.35, the default
pipe capacity is 16 pages, but the capacity can be queried and set
using the fcntl(2) F_GETPIPE_SZ and F_SETPIPE_SZ operations. See
fcntl(2) for more information.
- 1 回答
- 0 關注
- 152 瀏覽
添加回答
舉報