rwmutex

package
v0.0.0-...-c4191a4 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package rwmutex provides switch of concurrent safety feature for sync.RWMutex.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RWMutex

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

RWMutex is a sync.RWMutex with a switch for concurrent safe feature. If its attribute *sync.RWMutex is not nil, it means it's in concurrent safety usage. Its attribute *sync.RWMutex is nil in default, which makes this struct mush lightweight.

func Create

func Create(safe ...bool) RWMutex

Create creates and returns a new RWMutex 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) *RWMutex

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

func (*RWMutex) IsSafe

func (mu *RWMutex) IsSafe() bool

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

func (*RWMutex) Lock

func (mu *RWMutex) Lock()

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

func (*RWMutex) RLock

func (mu *RWMutex) RLock()

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

func (*RWMutex) RUnlock

func (mu *RWMutex) RUnlock()

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

func (*RWMutex) Unlock

func (mu *RWMutex) 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