gmutex

package
v2.7.8 Latest Latest
Warning

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

Go to latest
Published: Oct 13, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package gmutex inherits and extends sync.Mutex and sync.RWMutex with more futures.

Note that, it is refracted using stdlib mutex of package sync from GoFrame version v2.5.2.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mutex

type Mutex struct {
	sync.Mutex
}

Mutex is a high level Mutex, which implements more rich features for mutex.

func (*Mutex) LockFunc

func (m *Mutex) LockFunc(f func())

LockFunc locks the mutex for writing with given callback function `f`. If there's a write/reading lock the mutex, it will block until the lock is released.

It releases the lock after `f` is executed.

func (*Mutex) TryLockFunc

func (m *Mutex) TryLockFunc(f func()) (result bool)

TryLockFunc tries locking the mutex for writing with given callback function `f`. it returns true immediately if success, or if there's a write/reading lock on the mutex, it returns false immediately.

It releases the lock after `f` is executed.

type RWMutex added in v2.7.2

type RWMutex struct {
	sync.RWMutex
}

RWMutex is a high level RWMutex, which implements more rich features for mutex.

func New

func New() *RWMutex

New creates and returns a new mutex. Deprecated: use Mutex or RWMutex instead.

func (*RWMutex) LockFunc added in v2.7.2

func (m *RWMutex) LockFunc(f func())

LockFunc locks the mutex for writing with given callback function `f`. If there's a write/reading lock the mutex, it will block until the lock is released.

It releases the lock after `f` is executed.

func (*RWMutex) RLockFunc added in v2.7.2

func (m *RWMutex) RLockFunc(f func())

RLockFunc locks the mutex for reading with given callback function `f`. If there's a writing lock the mutex, it will block until the lock is released.

It releases the lock after `f` is executed.

func (*RWMutex) TryLockFunc added in v2.7.2

func (m *RWMutex) TryLockFunc(f func()) (result bool)

TryLockFunc tries locking the mutex for writing with given callback function `f`. it returns true immediately if success, or if there's a write/reading lock on the mutex, it returns false immediately.

It releases the lock after `f` is executed.

func (*RWMutex) TryRLockFunc added in v2.7.2

func (m *RWMutex) TryRLockFunc(f func()) (result bool)

TryRLockFunc tries locking the mutex for reading with given callback function `f`. It returns true immediately if success, or if there's a writing lock on the mutex, it returns false immediately.

It releases the lock after `f` is executed.

Jump to

Keyboard shortcuts

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