go-criticalsection: github.com/orkunkaraduman/go-criticalsection Index | Files

package criticalsection

import "github.com/orkunkaraduman/go-criticalsection"

Package criticalsection is discontinued. Please visit: github.com/orkunkaraduman/go-syncex

Index

Package Files

criticalsection.go error.go section.go utils.go

Variables

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

Library specific errors.

type CriticalSection Uses

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

A CriticalSection is a kind of lock like mutex. But it doesn't block first locked goroutine/section again.

A CriticalSection must not be copied after first use.

func (*CriticalSection) Lock Uses

func (cs *CriticalSection) Lock()

Lock locks cs. If the lock is already in use different goroutine, the different goroutine blocks until the CriticalSection is available.

func (*CriticalSection) LockSection Uses

func (cs *CriticalSection) LockSection(sc Section)

LockSection locks cs by given section. LockSection is faster than Lock(). If the lock is already in use different section, the different section blocks until the CriticalSection is available.

func (*CriticalSection) Unlock Uses

func (cs *CriticalSection) Unlock()

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

type Section Uses

type Section uint64

A Section is an identifier of sections.

func NewSection Uses

func NewSection() Section

NewSection creates a new Section.

Package criticalsection imports 6 packages (graph). Updated 2018-12-25. Refresh now. Tools for package owners.