buffered channel

A channel created with a capacity, such as make(chan int, 2), that can hold that many values before a send has to wait.

In more detail

An unbuffered channel has no space, so every send waits for a receiver. A buffer lets a sender run ahead by a bounded amount, which is useful for a results channel sized to the number of workers or a signal channel of size one. Size it deliberately rather than to hide a design problem.

Example

results := make(chan string, 2)

Related terms

Taught in

References