syncex

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2018 License: BSD-3-Clause Imports: 6 Imported by: 0

README

syncex

GoDoc

Extended synchronization for GoLang.

syncex includes:

  • RecursiveMutex (ReentrantMutex)
  • CriticalSection

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotLocked = errors.New("not locked")
)

Package specific errors.

Functions

func NewOwnerID

func NewOwnerID() uint64

NewOwnerID gives a new ownerID incrementally.

Types

type CriticalSection

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

A CriticalSection is particular type of mutual exclusion (mutex) that may be locked multiple times by the same owner.

The CriticalSection is faster than RecursiveMutex.

A CriticalSection must not be copied after first use.

func (*CriticalSection) Lock

func (cs *CriticalSection) Lock(ownerID uint64)

Lock locks cs with given ownerID. If cs is already owned by different owner, it waits until the CriticalSection is available.

func (*CriticalSection) Unlock

func (cs *CriticalSection) Unlock()

Unlock unlocks cs. It panics if cs is not locked on entry to Unlock.

type RecursiveMutex added in v1.1.0

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

A RecursiveMutex is particular type of mutual exclusion (mutex) that may be locked multiple times by the same goroutine.

A RecursiveMutex must not be copied after first use.

func (*RecursiveMutex) Lock added in v1.1.0

func (rm *RecursiveMutex) Lock()

Lock locks rm. If rm is already owned by different goroutine, it waits until the RecursiveMutex is available.

func (*RecursiveMutex) Unlock added in v1.1.0

func (rm *RecursiveMutex) Unlock()

Unlock unlocks rm. It panics if rm is not locked on entry to Unlock.

type ReentrantMutex

type ReentrantMutex RecursiveMutex

ReentrantMutex is synonym for RecursiveMutex.

Jump to

Keyboard shortcuts

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