An open API service indexing awesome lists of open source software.

https://github.com/titikterang/gotong-royong

to help us controll goroutine
https://github.com/titikterang/gotong-royong

concurrency concurrent-programming golang golang-examples golang-library goroutine goroutine-pool

Last synced: about 1 month ago
JSON representation

to help us controll goroutine

Awesome Lists containing this project

README

        

### Overview
gotong-royong is a simple library to help us limit goroutine

### Example Code
```go
package main

import (
"github.com/ujunglangit-id/gotong-royong/pkg"
"log"
"sync"
"time"
)

func showText() {
time.Sleep(2 * time.Second)
log.Printf(
"remaining queue : %d, current channel length %d, execute current task ....\n",
wk.GetRemainingQueueLength(), wk.GetChannelLength())
}

var (
wk *pkg.WorkerContainer
)

func init() {
wk = pkg.NewWorkers(5)
}

func main() {
wg := sync.WaitGroup{}
wk.RunInBackground()
for i := 0; i < 100; i++ {
go wk.AddNewEvent(showText)
}
wg.Add(1)
//your other logic / business flow in here
wg.Wait()
}
```