Skip to content

A concurrent toolkit to help execute funcs concurrently in an efficient and safe way. It supports specifying the overall timeout to avoid blocking.

License

Notifications You must be signed in to change notification settings

ITcathyh/conexec

Repository files navigation

Introduction

Build Status codecov Go Report Card GoDoc

conexec is a concurrent toolkit to help execute funcs concurrently in an efficient and safe way.It supports specifying the overall timeout to avoid blocking.

How to use

Generally it can be set as a singleton to save memory.Here is the example to use it.

	c := NewActuator()
	c.WithTimeOut(time.Second) // set time out
	err := c.Exec(
		func() error {
			fmt.Println(1)
			time.Sleep(time.Second * 2)
			return nil
		},
		func() error {
			fmt.Println(2)
			return nil
		},
		func() error {
			time.Sleep(time.Second * 1)
			fmt.Println(3)
			return nil
		},
	)
	
	if err != nil {
		// ...do sth
	}

About

A concurrent toolkit to help execute funcs concurrently in an efficient and safe way. It supports specifying the overall timeout to avoid blocking.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages