1
0
Fork 0
gobelt/threadpool
Gregory Eremin 993153693a Move readme parts to their corresponding packages 2018-07-03 20:33:55 +02:00
..
README.md Move readme parts to their corresponding packages 2018-07-03 20:33:55 +02:00
threadpool.go Add thread pool implementation 2018-06-17 12:57:47 +02:00
threadpool_test.go Add thread pool implementation 2018-06-17 12:57:47 +02:00

README.md

Thread pool

Package thread_pool implements a pool of threads, duh.

import "github.com/localhots/gobelt/threadpool"
ctx := context.Background()
ctx, cancel = context.WithTimeout(ctx, 30*time.Second)
defer cancel()

pool := threadpool.New(10)
defer pool.Close()
for i := 0; i < 1000000; i++ {
    i := i
    pool.Enqueue(ctx, func() {
        fmt.Printf("The number is %d\n", i)
    })
}