v0.0.0-...-5c114db Latest Latest

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

Go to latest
Published: Nov 2, 2023 License: MIT Imports: 2 Imported by: 0



Package softlock is a multistage asynchronous lock suitable for use in multiprocess sempahore.



This section is empty.


This section is empty.


This section is empty.


type SoftLock

type SoftLock struct {
	// contains filtered or unexported fields

SoftLock implements an idepotent two stage locking mechanism based on channels to allow for asynchronous triggering of waiting goroutines. Once it has been used, it cannot be reused.

func NewSoftLock

func NewSoftLock() *SoftLock

NewSoftLock creates a new SoftLock instance.

func (*SoftLock) Close

func (l *SoftLock) Close()

Close forces the soft lock to be done, and we can exit.

func (*SoftLock) Done

func (l *SoftLock) Done()

Done indicates all the soft lock work is finished, and we can exit.

func (*SoftLock) Finished

func (l *SoftLock) Finished() bool

Finished returns true if the lock is finished

func (*SoftLock) Release

func (l *SoftLock) Release()

Release the soft lock allowing waiting goroutines to continue.

func (*SoftLock) Released

func (l *SoftLock) Released() bool

Released returns true if the main wait lock has been released

func (*SoftLock) Start

func (l *SoftLock) Start() bool

Start the lock and return true if we started, false if we were already started.

func (*SoftLock) Started

func (l *SoftLock) Started() bool

Started returns whether or not we've started our transaction.

func (*SoftLock) String

func (l *SoftLock) String() string

func (*SoftLock) Wait

func (l *SoftLock) Wait()

Wait for the soft lock to be released. If the lock has not been started, this will be a passthrough.

func (*SoftLock) WaitForDone

func (l *SoftLock) WaitForDone()

WaitForDone waits for the soft lock to completely finish its lifecycle. This will block regardless of whether the lock has started or not.

func (*SoftLock) WaitForStart

func (l *SoftLock) WaitForStart()

WaitForStart waits for the soft lock to start. If the lock has already been started, this will be a passthrough.

Jump to

Keyboard shortcuts

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