mutex

package
v1.13.0-alpha2 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2022 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package mutex implements the sync.Locker interface using x/sync/semaphore. It may be used as a replacement for sync.Mutex when one or more goroutines need to allow their calls to Lock to be cancelled by context cancellation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

type Mutex semaphore.Weighted

func New

func New() *Mutex

New returns a Mutex that is ready for use.

func (*Mutex) Lock

func (m *Mutex) Lock()

func (*Mutex) TryLock

func (m *Mutex) TryLock(ctx context.Context) error

TryLock acquires the mutex, blocking until resources are available or ctx is done. On success, returns nil. On failure, returns ctx.Err() and leaves the semaphore unchanged.

If ctx is already done, Acquire may still succeed without blocking.

func (*Mutex) Unlock

func (m *Mutex) Unlock()

Jump to

Keyboard shortcuts

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