{"id":16816742,"url":"https://github.com/o1egl/syncx","last_synced_at":"2025-04-11T02:21:44.987Z","repository":{"id":144204706,"uuid":"77462018","full_name":"o1egl/syncx","owner":"o1egl","description":"SyncX is GO's sync package extensins","archived":false,"fork":false,"pushed_at":"2017-10-25T17:47:18.000Z","size":8,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T23:41:30.458Z","etag":null,"topics":["concurrency-library","go","golang","semaphore","sync","synchronization","thread","waitgroup"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/o1egl.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-27T14:39:50.000Z","updated_at":"2020-06-28T07:09:24.000Z","dependencies_parsed_at":"2023-06-19T04:35:55.308Z","dependency_job_id":null,"html_url":"https://github.com/o1egl/syncx","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o1egl%2Fsyncx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o1egl%2Fsyncx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o1egl%2Fsyncx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/o1egl%2Fsyncx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/o1egl","download_url":"https://codeload.github.com/o1egl/syncx/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248328459,"owners_count":21085321,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency-library","go","golang","semaphore","sync","synchronization","thread","waitgroup"],"created_at":"2024-10-13T10:45:13.617Z","updated_at":"2025-04-11T02:21:44.967Z","avatar_url":"https://github.com/o1egl.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![License](http://img.shields.io/:license-mit-blue.svg)](LICENSE)\n[![GoDoc](https://godoc.org/github.com/o1egl/syncx?status.svg)](https://godoc.org/github.com/o1egl/syncx)\n[![Build Status](http://img.shields.io/travis/o1egl/syncx.svg?style=flat-square)](https://travis-ci.org/o1egl/syncx)\n[![Coverage Status](http://img.shields.io/coveralls/o1egl/syncx.svg?style=flat-square)](https://coveralls.io/r/o1egl/syncx)\n# SyncX\n\nSyncX is a GO library that extends standard sync package.\n\n## Install\n\n```\n$ go get -u github.com/o1egl/syncx\n```\n\n## Usage\n* [AdwancedWaitGroup](#adwancedwaitgroup)\n* [Semaphore](#semaphore)\n\n### AdwancedWaitGroup\n\nAWG -  advanced version of wait group\n\nAdded features:\n\n* thread safe\n* integrated context.Context\n* execution timeout\n* ability to return errors\n* panic handling from goroutines\n\n```go\n    wg := awg.AdvancedWaitGroup{}\n\n    // Add first task\n    wg.Add(func() error {\n    \t//Logic\n    \treturn nil\n    })\n\n    // Add second task\n    wg.Add(func() error {\n    \t//Another Logic\n    \treturn nil\n    })\n\n    wg.Start()\n\n    var err error\n    // Taking one error make sense if you use *.SetStopOnError(true)* option - see below\n    err = wg.SetStopOnError(true).Start().GetLastError()\n\n    // Taking all errors\n    var errs []error\n    errs = wg.Start().GetAllErrors()    \n\n```\n\nIntegrated with context.Context. It gives you ability to set timeouts and register cancel functions\n\n```go\n    // SetTimeout defines timeout for all tasks\n    SetTimeout(t time.Duration)\n\n    // SetContext defines Context\n    SetContext(t context.Context)\n\n    // SetStopOnError stops waitgroup if any task returns error\n    SetStopOnError(b bool)\n\n    // Add adds new tasks into waitgroup\n    Add(funcs ...WaitgroupFunc)\n\n    // // Start runs tasks in separate goroutines and waits for their completion\n    Start()\n\n    // Reset performs cleanup task queue and reset state\n    Reset()\n\n    // // LastError returns last error that caught by execution process\n    LastError()\n\n    // AllErrors returns all errors that caught by execution process\n    AllErrors()\n\n    // Status returns result state\n    Status()\n```\n\n\n### Semaphore\n\n```go\n    // NewSemaphore returns new Semaphore instance\n    NewSemaphore(10)\n\n    //Acquire acquires one permit, if its not available the goroutine will block till its available or Context.Done() occurs.\n    //You can pass context.WithTimeout() to support timeoutable acquire.\n    Acquire(ctx context.Context)\n\n    //AcquireMany is similar to Acquire() but for many permits\n    //Returns successfully acquired permits.\n    AcquireMany(ctx context.Context, n int) (int, error)\n\n    //Release releases one permit\n    Release()\n\n    //ReleaseMany releases many permits\n    ReleaseMany(n int) error\n\n    //AvailablePermits returns number of available unacquired permits\n    AvailablePermits() int\n\n    //DrainPermits acquires all available permits and return the number of permits acquired\n    DrainPermits() (int, error)\n```\n\n\n\n## Copyright, License \u0026 Contributors\n\n### Submitting a Pull Request\n\n1. Fork it.\n2. Open a [Pull Request](https://github.com/o1egl/syncx/pulls)\n3. Enjoy a refreshing Diet Coke and wait\n\nSyncX is released under the MIT license. See [LICENSE](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fo1egl%2Fsyncx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fo1egl%2Fsyncx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fo1egl%2Fsyncx/lists"}