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 ¶
type SimpleMutex chan struct{}
SimpleMutex is a channel used for locking.
func NewSimpleMutex ¶
func NewSimpleMutex() SimpleMutex
NewSimpleMutex creates and returns a new SimpleMutex object.
func (SimpleMutex) TryLock ¶
func (s SimpleMutex) TryLock() bool
TryLock attempts to acquire a lock on the mutex. Returns true if the lock has been acquired, false otherwise.