gf: github.com/johng-cn/gf/g/os/gflock Index | Files

package gflock

import "github.com/johng-cn/gf/g/os/gflock"

Package gflock implements a concurrent-safe sync.Locker interface for file locking.

Index

Package Files

gflock.go

type Locker Uses

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

File locker.

func New Uses

func New(file string) *Locker

New creates and returns a new file locker with given <file>. The parameter <file> usually is a absolute file path.

func (*Locker) IsLocked Uses

func (l *Locker) IsLocked() bool

IsLocked returns whether the locker is locked.

func (*Locker) Lock Uses

func (l *Locker) Lock() (err error)

func (*Locker) Path Uses

func (l *Locker) Path() string

Path returns the file path of the locker.

func (*Locker) RLock Uses

func (l *Locker) RLock() (err error)

func (*Locker) RUnlock Uses

func (l *Locker) RUnlock() (err error)

func (*Locker) TryLock Uses

func (l *Locker) TryLock() bool

TryLock tries get the writing lock of the locker. It returns true if success, or else returns false immediately.

func (*Locker) TryRLock Uses

func (l *Locker) TryRLock() bool

TryRLock tries get the reading lock of the locker. It returns true if success, or else returns false immediately.

func (*Locker) UnLock Uses

func (l *Locker) UnLock() (err error)

Package gflock imports 3 packages (graph). Updated 2019-06-19. Refresh now. Tools for package owners.