Skip to content
/ flow Public

🌊Flow is an easy-used synchronize model

Notifications You must be signed in to change notification settings

BouncyElf/flow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
liuqiangqiang
Mar 11, 2025
2c2ade5 Â· Mar 11, 2025

History

26 Commits
Mar 11, 2025
Mar 11, 2025
Mar 11, 2025
Mar 11, 2025
Apr 3, 2019

Repository files navigation

Flow

🌊Flow is an easy-used concurrent calculate model in Go.

Flow can easily limit the maxium number of concurrent goroutine and can be very straight-forward to use.

Basically, flow is a 2D matrix and it run jobs row-by-row which in same row, the jobs will run concurrently.

Example

package main

import (
	"fmt"

	"github.com/BouncyElf/flow"
)

func main() {
	f, counter := flow.New(), 0
	// declare a job
	showLevel := func() {
		counter++
		fmt.Println("level", counter)
	}
	// Next starts a new level, and put the job `showLevel` in it
	f.Next(showLevel)
	for i := 0; i < 20; i++ {
		v := i
		// With add job in this level
		f.With(func() {
			// do some stuff
			fmt.Println(v)
		})
	}
	// start a new level
	f.Next(showLevel)
	for i := 0; i < 20; i++ {
		v := i
		f.With(func() {
			// do some stuff
			fmt.Println(v)
		})
	}
	// limit the number of concurrent jobs
	f.Limit(10)
	// wait and execute job
	f.Run()
}

Doc

GoDoc

About

🌊Flow is an easy-used synchronize model

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages