Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
Run executes the provided functions in concurrent and collects any errors they return. Be careful about your resource consumption.
Example ¶
Run concurrently your func() error.
package main import ( "fmt" "sync/atomic" "github.com/donutloop/toolkit/concurrent" ) func main() { counter := int32(0) errs := concurrent.Run( func() error { atomic.AddInt32(&counter, 40) return nil }, func() error { atomic.AddInt32(&counter, 2) return nil }, ) if len(errs) > 0 { for _, err := range errs { fmt.Printf("error: %v \n", err) } } fmt.Println(counter) }
Output: 42
Types ¶
type RecoverError ¶
type RecoverError struct { Err interface{} Stack []byte }
func (*RecoverError) Error ¶
func (e *RecoverError) Error() string
Click to show internal directories.
Click to hide internal directories.