Documentation
¶
Index ¶
Constants ¶
const ( QueueLatestElement = -1 QueueBeforeLatestElement = -2 )
various constants
Variables ¶
var ( ErrQueueIsEmpty = errors.New("queue is empty") ErrQueueOverflowed = errors.New("queue overflowed") ErrFailedToDrop = func(err error) error { return fmt.Errorf("failed to drop element: %v", err) } ErrOutOfBounds = errors.New("index out of bounds") )
errors
Functions ¶
This section is empty.
Types ¶
type Counter ¶
Counter that is thread-safe
func NewCounter ¶
NewCounter returns a new synced counter initialized by initialValue
func (*Counter) MarshalJSON ¶ added in v1.0.3
MarshalJSON implements json.Marshaler
func (*Counter) UnmarshalJSON ¶ added in v1.0.3
UnmarshalJSON implements json.Unmarshaler
type Flag ¶
Flag that is thread-safe
func (*Flag) MarshalJSON ¶ added in v1.0.3
MarshalJSON implements json.Marshaler
func (*Flag) UnmarshalJSON ¶ added in v1.0.3
UnmarshalJSON implements json.Unmarshaler
type Mutex ¶ added in v1.0.5
type Mutex struct {
BeforeLock func()
AfterLock func()
BeforeUnlock func()
AfterUnlock func()
AfterUnlockRecover func(r interface{})
// contains filtered or unexported fields
}
Mutex adds debugging-related functionality to sync.Mutex. It is coded on top of sync.RWMutex to minimize code duplication.
func NewMutex ¶ added in v1.0.5
func NewMutex(p MutexParams) *Mutex
NewMutex returns a pointer to a new Mutex with default callbacks assigned
func (*Mutex) Lock ¶ added in v1.0.5
func (m *Mutex) Lock()
Lock calls the underlying Mutex.Lock method. BeforeLock and AfterLock callbacks will be executed before and after such call respectively. If callback was not specified, it will be ignored.
func (*Mutex) LockWithTag ¶ added in v1.1.3
LockWithTag works like Lock but adds a specified tag to help in debugging process
func (*Mutex) Unlock ¶ added in v1.0.5
func (m *Mutex) Unlock()
Unlock calls the underlying Mutex.Unlock method. BeforeUnlock and AfterUnlock callbacks will be executed before and after such call respectively. If a panic will occur at underlying Mutex unlocking, it will be handled by a call to recover() and BeforeUnlockRecover and AfterUnlockRecover will be called respectively. If callback was not specified, it will be ignored.
type MutexParams ¶ added in v1.1.0
type MutexParams struct {
Name string
SetDefaultCallbacks bool
AddStackTrace bool
Timeout time.Duration
}
MutexParams are mutex parameters
type Queue ¶
Queue that is thread-safe
func NewDroppingQueue ¶
NewDroppingQueue returns a new synced dropping queue
func NewLimitedQueue ¶
NewLimitedQueue returns a new synced limited queue
func (*Queue) Get ¶
Get element at position pos but don't pop it, 0 is the most early element, -1 is the latest
type RWMutex ¶ added in v1.0.5
type RWMutex struct {
*Mutex
BeforeRLock func()
AfterRLock func()
BeforeRUnlock func()
AfterRUnlock func()
AfterRUnlockRecover func(r interface{})
}
RWMutex adds debugging-related functionality to sync.RWMutex
func NewRWMutex ¶ added in v1.0.5
func NewRWMutex(p MutexParams) *RWMutex
NewRWMutex returns a pointer to a new RWMutex with default callbacks assigned
func (*RWMutex) RLock ¶ added in v1.0.5
func (m *RWMutex) RLock()
RLock calls the underlying RWMutex.RLock method. BeforeRLock and AfterRLock callbacks will be executed before and after such call respectively. If callback was not specified, it will be ignored.
func (*RWMutex) RUnlock ¶ added in v1.0.5
func (m *RWMutex) RUnlock()
RUnlock calls the underlying RWMutex.RUnlock method. BeforeRUnlock and AfterRUnlock callbacks will be executed before and after such call respectively. If a panic will occur at underlying RWMutex unlocking, it will be handled by a call to recover() and BeforeRUnlockRecover and AfterRUnlockRecover will be called respectively. If callback was not specified, it will be ignored.