Documentation
¶
Overview ¶
Package gchan provides graceful channel for no panic operations.
It's safe to call Chan.Push/Close functions repeatedly.
Example (Basic) ¶
package main
import (
"fmt"
"github.com/gogf/gf/container/gchan"
)
func main() {
n := 10
c := gchan.New(n)
for i := 0; i < n; i++ {
c.Push(i)
}
fmt.Println(c.Len(), c.Cap())
for i := 0; i < n; i++ {
fmt.Print(c.Pop())
}
c.Close()
}
Output: 10 10 0123456789
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Chan ¶
type Chan struct {
// contains filtered or unexported fields
}
Graceful channel.
func (*Chan) Close ¶
func (c *Chan) Close()
Close closes the channel. It is safe to be called repeatedly.
func (*Chan) Pop ¶
func (c *Chan) Pop() interface{}
Pop pops value from channel. If there's no value in channel, it would block to wait. If the channel is closed, it will return a nil value immediately.
Click to show internal directories.
Click to hide internal directories.