lock

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2024 License: MIT Imports: 2 Imported by: 1

Documentation

Overview

Package lock is the equivalent of sync.Mutex but with a context.

Prefer standard sync.Mutex if you don't use the context.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Lock

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

Lock is like a mutex but with ctx.

func New

func New() *Lock

func (*Lock) Lock

func (l *Lock) Lock()

Lock bocks other calls until Unlock() is called.

See LockWithContext()

func (*Lock) LockWithContext

func (l *Lock) LockWithContext(ctx context.Context) error

LockWithContext bocks other calls until Unlock() is called or the context is cancelled. It forwards the context error when cancelled.

func (*Lock) Unlock

func (l *Lock) Unlock()

type Locker

type Locker interface {
	LockWithContext(ctx context.Context) error
	Unlock()
	Lock()
}

Jump to

Keyboard shortcuts

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