Documentation ¶
Overview ¶
Package concurrency is a very simple implementation of a mutex with channels. Provides TryLock functionality absent in Go's regular sync.Mutex. See https://github.com/golang/go/issues/6123 for details.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GoRoutinePool ¶
type GoRoutinePool struct {
// contains filtered or unexported fields
}
GoRoutinePool is a pull of Go routines with associated locking mechanism.
func NewGoRoutinePool ¶
func NewGoRoutinePool(numWorkers int) *GoRoutinePool
NewGoRoutinePool allocates a new thread pool with `numWorkers` goroutines.
func (*GoRoutinePool) Schedule ¶
func (p *GoRoutinePool) Schedule(task Task)
Schedule enqueus a closure to run on the GoRoutinePool's goroutines.
func (*GoRoutinePool) Stop ¶
func (p *GoRoutinePool) Stop()
Stop sends a stop signal to all running goroutines.
type SimpleMutex ¶ added in v0.16.9
type SimpleMutex chan struct{}
SimpleMutex is a channel used for locking.
func NewSimpleMutex ¶ added in v0.16.9
func NewSimpleMutex() SimpleMutex
NewSimpleMutex creates and returns a new SimpleMutex object.
func (SimpleMutex) Lock ¶ added in v0.16.9
func (s SimpleMutex) Lock()
Lock acquires a lock on the mutex.
func (SimpleMutex) TryLock ¶ added in v0.16.9
func (s SimpleMutex) TryLock() bool
TryLock attempts to acquire a lock on the mutex. Returns true if the lock has been acquired, false otherwise.
func (SimpleMutex) Unlock ¶ added in v0.16.9
func (s SimpleMutex) Unlock()
Unlock releases the mutex.