Package locker

import "github.com/BurntSushi/locker"
Overview
Index

Overview ▾

Package locker is a simple package to manage named ReadWrite mutexes. These appear to be especially useful for synchronizing access to session based information in web applications.

The common use case is to use the package level functions, which use a package level set of locks (safe to use from multiple goroutines simultaneously). However, you may also create a new separate set of locks.

All locks are implemented with read-write mutexes. To use them like a regular mutex, simply ignore the RLock/RUnlock functions.

func Lock

func Lock(key string)

func RLock

func RLock(key string)

func RUnlock

func RUnlock(key string)

func Unlock

func Unlock(key string)

type Locker

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

Locker represents the set of named ReadWrite mutexes. It is safe to access from multiple goroutines simultaneously.

func NewLocker

func NewLocker() *Locker

func (*Locker) Lock

func (lker *Locker) Lock(key string)

func (*Locker) RLock

func (lker *Locker) RLock(key string)

func (*Locker) RUnlock

func (lker *Locker) RUnlock(key string)

func (*Locker) Unlock

func (lker *Locker) Unlock(key string)

Bugs