Skip to content

poolasync is a tool for goroutines with a pool.

License

Notifications You must be signed in to change notification settings

joy717/poolasync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Report Card

pool-async

pool-async is a tool for goroutines with a pool.

#Quick start

package main

import "github.com/joy717/poolasync"
import "fmt"

func main() {
  pa := poolasync.NewDefaultPoolAsync()
  pa.DoWitError(func() error {
    fmt.Println("goroutine 1")
    return nil
  }).DoWitError(func() error {
    fmt.Println("goroutine 2")
    return fmt.Errorf("goroutine 2 err")
  })
  
  // NOTICE: should call pa.Wait() always to complete the jobs.
  // because we use channel, Wait() is the reciver function.
  if err := pa.Wait(); err != nil {
    fmt.Println("the 1st non-nil err: ", err)
  }
}

If you like this tool, star it and share it. Thx.