Documentation
¶
Overview ¶
Package chanx 提供无界 channel 等 channel 扩展原语。
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Unbounded ¶
type Unbounded[T any] struct { // contains filtered or unexported fields }
Unbounded 是一个无界 channel:发送端永不阻塞(值缓存在内部切片中), 接收端从 Out() 读取,保持 FIFO 顺序。适合事件总线、日志队列等 "生产不可阻塞、消费可能滞后" 的场景。
使用:
u := chanx.NewUnbounded[int]() u.In() <- 1 v := <-u.Out() u.Close() // 关闭后 Out() 读完剩余值再关闭
Click to show internal directories.
Click to hide internal directories.