mutex

package
v2.2.4 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package mutex provides switch of concurrent safe feature for sync.Mutex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

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

Mutex is a sync.Mutex with a switch for concurrent safe feature.

func Create added in v2.2.0

func Create(safe ...bool) Mutex

Create creates and returns a new Mutex object. The parameter `safe` is used to specify whether using this mutex in concurrent safety, which is false in default.

func New

func New(safe ...bool) *Mutex

New creates and returns a new *Mutex. The parameter `safe` is used to specify whether using this mutex in concurrent safety, which is false in default.

func (*Mutex) IsSafe

func (mu *Mutex) IsSafe() bool

IsSafe checks and returns whether current mutex is in concurrent-safe usage.

func (*Mutex) Lock

func (mu *Mutex) Lock()

Lock locks mutex for writing. It does nothing if it is not in concurrent-safe usage.

func (*Mutex) Unlock

func (mu *Mutex) Unlock()

Unlock unlocks mutex for writing. It does nothing if it is not in concurrent-safe usage.

Jump to

Keyboard shortcuts

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