Thanks to visit codestin.com
Credit goes to Github.com

Skip to content

shomali11/xpool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xpool Build Status Go Report Card GoDoc License: MIT

A pool to facilitate the creation and reuse of objects

Examples

Example 1

Using NewPool to create a pool with capacity of 10.

package main

import (
	"github.com/shomali11/xpool"
	"time"
)

type Object struct{}

func main() {
	factory := func() interface{} {
		return &Object{}
	}

	pool := xpool.NewPool(10, factory)

	for i := 0; i < 10; i++ {
		go func() {
			object := pool.Get().(*Object)
			pool.Return(object)
		}()
	}

	time.Sleep(time.Second)
}

About

Go Pool

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages