package locker
import "github.com/BurntSushi/locker"
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.
Index ¶
- func Lock(key string)
- func RLock(key string)
- func RUnlock(key string)
- func Unlock(key string)
- type Locker
- func NewLocker() *Locker
- func (lker *Locker) Lock(key string)
- func (lker *Locker) RLock(key string)
- func (lker *Locker) RUnlock(key string)
- func (lker *Locker) Unlock(key string)
- Bugs
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)
Types ¶
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 (*Locker) RLock ¶
func (*Locker) RUnlock ¶
func (*Locker) Unlock ¶
Bugs ¶
☞ The locker here can grow without bound in long running programs. Since it's intended to be used in web applications, this is a major problem. Figure out a way to keep the locker lean.
Source Files ¶
- Version
- v0.0.0-20171006230638-a6e239ea1c69 (latest)
- Published
- Oct 6, 2017
- Platform
- linux/amd64
- Imports
- 2 packages
- Last checked
- 3 weeks ago –
Tools for package owners.