concurrency

package
v0.16.9-rc1 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2020 License: GPL-3.0 Imports: 0 Imported by: 0

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.

func (SimpleMutex) Unlock added in v0.16.9

func (s SimpleMutex) Unlock()

Releases the mutex.

type Task

type Task func()

Task represents a work task to be run on the specified thread pool.

Jump to

Keyboard shortcuts

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