Documentation
¶
Overview ¶
Copyright 2016 ~ 2018 AlexStocks(https://github.com/AlexStocks). All rights reserved. Use of this source code is governed by Apache License 2.0.
refers to github.com/jonhoo/drwmutex
Copyright 2016 ~ 2018 AlexStocks(https://github.com/AlexStocks). All rights reserved. Use of this source code is governed by Apache License 2.0.
refers to github.com/jonhoo/drwmutex
Package gxsync provides some synchronization primitives such as trylock & semaphore.
Copyright 2016 ~ 2018 AlexStocks(https://github.com/AlexStocks). All rights reserved. Use of this source code is governed by Apache License 2.0.
refers to github.com/jonhoo/drwmutex
this file provides a kind of unbouned channel
Index ¶
Constants ¶
const (
QSize = 64
)
Variables ¶
var (
ErrBroadcastClosed = fmt.Errorf("broadcast closed!")
)
Functions ¶
This section is empty.
Types ¶
type Broadcaster ¶
type Broadcaster struct {
// contains filtered or unexported fields
}
func (Broadcaster) Close ¶
func (b Broadcaster) Close()
func (Broadcaster) Write ¶
func (b Broadcaster) Write(value interface{}) (rerr error)
Node a value to all listeners.
type DRWMutex ¶ added in v0.3.0
type DRWMutex []paddedRWMutex
drwmutex provides a DRWMutex, a distributed RWMutex for use when there are many readers spread across many cores, and relatively few cores. DRWMutex is meant as an almost drop-in replacement for sync.RWMutex.
func NewDRWMutex ¶ added in v0.3.0
func NewDRWMutex() DRWMutex
New returns a new, unlocked, distributed RWMutex.
func (DRWMutex) Lock ¶ added in v0.3.0
func (mx DRWMutex) Lock()
Lock takes out an exclusive writer lock similar to sync.Mutex.Lock. A writer lock also excludes all readers.
func (DRWMutex) RLock ¶ added in v0.3.0
RLock takes out a non-exclusive reader lock, and returns the lock that was taken so that it can later be released.
func (DRWMutex) RLocker ¶ added in v0.3.0
RLocker returns a sync.Locker presenting Lock() and Unlock() methods that take and release a non-exclusive *reader* lock. Note that this call may be relatively slow, depending on the underlying system architechture, and so its result should be cached if possible.
type Mutex ¶ added in v0.3.0
type Mutex struct {
// contains filtered or unexported fields
}
Mutex is simple sync.Mutex + ability to try to Lock.
func (*Mutex) Lock ¶ added in v0.3.0
func (m *Mutex) Lock()
Lock locks m. If the lock is already in use, the calling goroutine blocks until the mutex is available.
func (*Mutex) TryLock ¶ added in v0.3.0
TryLock tries to lock m. It returns true in case of success, false otherwise.
func (*Mutex) Unlock ¶ added in v0.3.0
func (m *Mutex) Unlock()
Unlock unlocks m. It is a run-time error if m is not locked on entry to Unlock.
A locked Mutex is not associated with a particular goroutine. It is allowed for one goroutine to lock a Mutex and then arrange for another goroutine to unlock it.
type Once ¶ added in v0.3.0
type Once struct {
// contains filtered or unexported fields
}
Once is an object that will perform exactly one action until Reset is called. refer from github.com/matryer/resync
func (*Once) Do ¶ added in v0.3.0
func (o *Once) Do(f func())
Do simulates sync.Once.Do by executing the specified function only once, until Reset is called. See http://golang.org/pkg/sync/#Once
type Receiver ¶
type Receiver struct {
C chan Node
}
type Semaphore ¶
type Semaphore struct {
// contains filtered or unexported fields
}
func NewSemaphore ¶
type UnboundedChan ¶
type UnboundedChan struct {
// Q *gxqueue.Queue
Q *gxdeque.Deque
// contains filtered or unexported fields
}
refer from redisgo/redis/pool.go
func NewUnboundedChan ¶
func NewUnboundedChan() *UnboundedChan
func (*UnboundedChan) Close ¶
func (q *UnboundedChan) Close()
func (*UnboundedChan) Len ¶
func (q *UnboundedChan) Len() int
func (*UnboundedChan) Pop ¶
func (q *UnboundedChan) Pop() interface{}
func (*UnboundedChan) Push ¶
func (q *UnboundedChan) Push(v interface{})
func (*UnboundedChan) SetWaitOption ¶
func (q *UnboundedChan) SetWaitOption(wait bool)
在pop时,如果没有资源,是否等待 即使用乐观锁还是悲观锁
func (*UnboundedChan) TryPop ¶
func (q *UnboundedChan) TryPop() (interface{}, bool)
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package gxatomic provides simple wrappers around numerics to enforce atomic access.
|
Package gxatomic provides simple wrappers around numerics to enforce atomic access. |
|
Package gxerrgroup implements an actor-runner with deterministic teardown.
|
Package gxerrgroup implements an actor-runner with deterministic teardown. |
|
Package pool implements a pool of Object interfaces to manage and reuse them.
|
Package pool implements a pool of Object interfaces to manage and reuse them. |