Skip to content

lock-free/gopool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gopool

A pool library for golang

Quick Example

import (
  "github.com/lock-free/gopool"
  "time"
)

// define resource
type Res = func(int, int) int
res := func(a int, b int) int {
	return a + b
}

// create pool
getNewItem := func(onItemBoken gopool.OnItemBorken) (*gopool.Item, error) {
	return &gopool.Item{res, func() {}}, nil
}

pool := GetPool(getNewItem, 8, 3000*time.Millisecond)

// Get resource

res, err := pool.Get()

if err != nil {
  // handle
} else {
  res.(Res)(2, 3) // 5
}

About

A pool library for golang

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published