Documentation
¶
Index ¶
- func AsStream(done <-chan struct{}, values ...interface{}) <-chan interface{}
- func CreateCases(chs ...chan int) []reflect.SelectCase
- func FanInRec(chans ...<-chan interface{}) <-chan interface{}
- func FanInReflect(chans ...<-chan interface{}) <-chan interface{}
- func FanOut(ch <-chan interface{}, out []chan interface{}, async bool)
- func NewSemaphore(capacity int) sync.Locker
- func NewWorker(id int, ch chan Token, nextCh chan Token)
- func Or(channels ...<-chan interface{}) <-chan interface{}
- func OrDone(channels ...<-chan interface{}) <-chan interface{}
- func TakeN(done <-chan struct{}, valueStream <-chan interface{}, num int) <-chan interface{}
- type Mutex
- type Once
- type RWMap
- type RecursiveMutex
- type Token
- type TokenRecursiveMutex
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AsStream ¶
func AsStream(done <-chan struct{}, values ...interface{}) <-chan interface{}
AsStream 把一个slice转换为Stream
func CreateCases ¶
func CreateCases(chs ...chan int) []reflect.SelectCase
CreateCases 基于反射构建动态select
func FanInRec ¶
func FanInRec(chans ...<-chan interface{}) <-chan interface{}
FanInRec 二分递归加速多个chan往最终的一个chan扇入
func FanInReflect ¶
func FanInReflect(chans ...<-chan interface{}) <-chan interface{}
FanInReflect 多个chan 扇入到一个目标chan
func FanOut ¶
func FanOut(ch <-chan interface{}, out []chan interface{}, async bool)
FanOut chan的扇出事一个chan的数据往多个目标chan扇出
Types ¶
type Mutex ¶
type Mutex struct {
// contains filtered or unexported fields
}
Mutex 使用chan实现互斥锁
func (*Mutex) LockTimeout ¶
LockTimeout 加入一个超时的设置
type RecursiveMutex ¶
RecursiveMutex 包装一个Mutex,实现可重入
func (*RecursiveMutex) Lock ¶
func (m *RecursiveMutex) Lock()
func (*RecursiveMutex) Unlock ¶
func (m *RecursiveMutex) Unlock()
type TokenRecursiveMutex ¶
TokenRecursiveMutex Token方式的递归锁(可重入)
func (*TokenRecursiveMutex) Lock ¶
func (m *TokenRecursiveMutex) Lock(token int64)
Lock 请求锁,需要传入token
Click to show internal directories.
Click to hide internal directories.