Skip to content

gofika/fikasync

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codecov Build Status go.dev Go Report Card Licenses

fikasync

Utility designed for concurrent handling.

Basic Usage

Installation

To get the package, execute:

go get github.com/gofika/fikasync

Example

package main

import (
	"log"
	"time"

	"github.com/gofika/fikasync"
)

// fakeTask simulates a task that takes some time to complete.
func fakeTask(i int) {
	// your task code here...
	log.Printf("Executing task %d\n", i)
	// simulate some work
	time.Sleep(time.Second)
}

func main() {
	// create a new limiter that allows 5 concurrent operations
	limiter := fikasync.NewConcurrentLimiter(5)
	defer limiter.Close()

	// run 20 tasks
	for i := 0; i < 20; i++ {
		// run the task in a goroutine, blocking if the maximum number of concurrent operations has been reached
		limiter.Go(func() {
			fakeTask(i)
		})
	}

	limiter.Wait()
	log.Println("All tasks completed")
}

About

Utility designed for concurrent handling.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages