Skip to content
This repository has been archived by the owner on Feb 1, 2023. It is now read-only.

deweppro/go-chan-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Pool on Chan

Coverage Status Release Go Report Card Build Status

How to use it

import pool "github.com/deweppro/go-chan-pool"

type Object struct {
	I int64
}

func main() {
	cpool := &pool.ChanPool{
		Size: 1, // pool size
		New: func() interface{} { // handler for creating a new object in pool
			return &Object{}
		},
	}
	a := cpool.Get().(*Object) //get object from pool
	cpool.Put(a) //set object to pool
}