Skip to content

hiranya/goroutinepool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

goroutinepool

A simple goroutine pool for Golang.

goroutinepool uses channels as a semaphore to implement this.

Documentation

https://godoc.org/github.com/hiranya/goroutinepool

Example

See example/example1.go for a working example

package main

import (
	"fmt"
	"github.com/hiranya/goroutinepool"
)

func main() {
	cmd := &CounterCmd{}

	pool := goroutinepool.Pool{}

	// param1: number of iterations
	// param2: level of concurrency required
	// param3: the command/job to execute
	pool.Run(30, 10, cmd)
}

type CounterCmd struct {
}

// Provide an Exec() function to implement the Command interface provided by goroutinepool library
func (cmd *CounterCmd) Exec() {
	// -----
	// your time consuming job
	// -----
}

About

A simple goroutine pool for Golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages