Skip to content
/ cc Public

[MOVED] Tiny Go tool for running multiple functions concurrently and collecting their results into an error slice.

License

Notifications You must be signed in to change notification settings

mitranim/cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Moved to https://github.com/mitranim/gg. This repo is usable but frozen.

Overview

Short for "ConCurrent". Go tool for running multiple functions concurrently, collecting their errors into an error slice. Tiny and dependency-free.

API docs: https://pkg.go.dev/github.com/mitranim/cc.

Examples

import "github.com/mitranim/cc"

func ExampleAll() {
  err := cc.All(
    func() {
      fmt.Println(`running in background`)
    },
    func() {
      fmt.Println(`running in background`)
    },
  )
  fmt.Println(`done; no error:`, err == nil)

  // Output:
  // running in background
  // running in background
  // done; no error: true
}

func ExampleConc() {
  var conc cc.Conc

  conc.Add(func() {
    fmt.Println(`running in background`)
  })

  conc.Add(func() {
    fmt.Println(`running in background`)
  })

  fmt.Println(`starting`)

  err := conc.All()
  fmt.Println(`done; no error:`, err == nil)

  // Output:
  // starting
  // running in background
  // running in background
  // done; no error: true
}

License

https://unlicense.org

Misc

I'm receptive to suggestions. If this library almost satisfies you but needs changes, open an issue or chat me up. Contacts: https://mitranim.com/#contacts

About

[MOVED] Tiny Go tool for running multiple functions concurrently and collecting their results into an error slice.

Topics

Resources

License

Stars

Watchers

Forks