Documentation
¶
Overview ¶
*****************************************************************************
* * Description : * A very basic and naive implementation of thread pool. * ****************************************************************************
*****************************************************************************
* * Description : * 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
}
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{}
func NewSimpleMutex ¶ added in v0.16.9
func NewSimpleMutex() SimpleMutex
Creates and returns a new SimpleMutex object.
func (SimpleMutex) Lock ¶ added in v0.16.9
func (s SimpleMutex) Lock()
Acquires a lock on the mutex.
func (SimpleMutex) TryLock ¶ added in v0.16.9
func (s SimpleMutex) TryLock() bool
Attempts to acquire a lock on the mutex. Returns true if the lock has been acquired, false otherwise.
Click to show internal directories.
Click to hide internal directories.