Skip to content

speeder-allen/easy-pool

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

easy-pool

a easy pool for golang

test

Build Status

install

go get -v github.com/speeder-allen/easy-pool

how to use

this package define some pool, now version support:

  • routines pool

  • connection pool

routines pool

a pool to limit routines number.

pool := easy_pool.NewRoutines(3) // 3 is capacity of the pool

var wg sync.WaitGroup

wg.Add(4)

for i := 0; i < 4; i ++ {
    go func(){
        defer wg.Done()
        pool.Take() // three routines will get pool, and one routines will block
    }()
}

go func(){
    time.Sleep(time.Second * 10)
    pool.Put(easy_pool.EmptyConn()) // after ten seconds ,a pool put to pool, so the last routines get pool and exit
}()

wg.Wait() // now will block until the last routine get pool and exit

About

a easy general pool for golang

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages