sync_locker

package
v0.8.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 11, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Locker

type Locker struct {
	// contains filtered or unexported fields
}

Locker 写锁对象

func NewLocker

func NewLocker(logger glog.ILogger) *Locker

NewLocker 创建新的锁对象

func (*Locker) Lock

func (l *Locker) Lock(timeout int) (successful bool, prevStack string, currStack string)

Lock 尝试加锁,如果在指定的时间内失败,则会返回失败;否则返回成功 timeout:指定的毫秒数,timeout<=0则将会死等 返回值: 成功或失败 如果失败,返回上一次成功加锁时的堆栈信息 如果失败,返回当前的堆栈信息

func (*Locker) Unlock

func (l *Locker) Unlock()

Unlock 解锁

func (*Locker) WaitLock

func (l *Locker) WaitLock()

WaitLock 锁定(死等方式)

type RWLocker

type RWLocker struct {
	// contains filtered or unexported fields
}

RWLocker 读写锁对象

func NewRWLocker

func NewRWLocker(logger glog.Logger) *RWLocker

NewRWLocker 创建新的读写锁对象

func (*RWLocker) Lock

func (l *RWLocker) Lock(timeout int) (successful bool, prevStack string, currStack string)

Lock 写锁定 timeout:超时毫秒数,timeout<=0则将会死等 返回值: 成功或失败 如果失败,返回上一次成功加锁时的堆栈信息 如果失败,返回当前的堆栈信息

func (*RWLocker) RLock

func (l *RWLocker) RLock(timeout int) (successful bool, prevStack string, currStack string)

RLock 读锁定 timeout:超时毫秒数,timeout<=0则将会死等 返回值: 成功或失败 如果失败,返回上一次成功加锁时的堆栈信息 如果失败,返回当前的堆栈信息

func (*RWLocker) RUnlock

func (l *RWLocker) RUnlock()

RUnlock 释放读锁

func (*RWLocker) Unlock

func (l *RWLocker) Unlock()

Unlock 释放写锁

func (*RWLocker) WaitLock

func (l *RWLocker) WaitLock()

WaitLock 写锁定(死等)

func (*RWLocker) WaitRLock

func (l *RWLocker) WaitRLock()

WaitRLock 读锁定(死等)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL