Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EasyBarrier ¶
type EasyBarrier struct {
// contains filtered or unexported fields
}
EasyBarrier 是一个简单的同步机制,允许多个 goroutine 协调并等待彼此完成。
func NewEasyBarrier ¶
func NewEasyBarrier(num_workers int) *EasyBarrier
NewEasyBarrier 创建一个新的 EasyBarrier。 参数 num_workers 指定需要同步的 worker 数量。
func (*EasyBarrier) Done ¶
func (barrier *EasyBarrier) Done()
Done 表示一个 worker 已经完成。 调用此方法会向 ready 通道发送一个信号。
func (*EasyBarrier) Sync ¶
func (barrier *EasyBarrier) Sync()
Sync 等待所有 worker 完成。 调用此方法会阻塞,直到所有 worker 都调用了 Done。
type LightBarrier ¶
type LightBarrier struct {
// contains filtered or unexported fields
}
LightBarrier 使用 sync.Cond 和计数器实现的同步机制。
Click to show internal directories.
Click to hide internal directories.