{"id":17340426,"url":"https://github.com/mostynb/zstdpool-freelist","last_synced_at":"2025-03-27T08:40:50.542Z","repository":{"id":65927894,"uuid":"314374719","full_name":"mostynb/zstdpool-freelist","owner":"mostynb","description":null,"archived":false,"fork":false,"pushed_at":"2020-12-29T11:32:18.000Z","size":12,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-01T13:29:49.125Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mostynb.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}},"created_at":"2020-11-19T21:30:55.000Z","updated_at":"2021-10-06T21:28:05.000Z","dependencies_parsed_at":"2023-02-16T17:45:33.799Z","dependency_job_id":null,"html_url":"https://github.com/mostynb/zstdpool-freelist","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-freelist","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-freelist/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-freelist/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mostynb%2Fzstdpool-freelist/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mostynb","download_url":"https://codeload.github.com/mostynb/zstdpool-freelist/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245812949,"owners_count":20676723,"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":[],"created_at":"2024-10-15T15:45:04.382Z","updated_at":"2025-03-27T08:40:50.517Z","avatar_url":"https://github.com/mostynb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zstdpool\n\nZstdpool provides flexible pool implementations for the Encoder and Decoder\ntypes in github.com/klauspost/compress/zstd which do not leak goroutines.\n\n## Why not use sync.Pool?\n\n`zstd.Encoder` leaks goroutines if it is garbage collected without `Close()`\nbeing called first. So we can't safely put an unclosed encoder in a sync.Pool.\nBut encoders cannot be reused after being closed, so we can't put a closed\nencoder in a sync.Pool either.\n\n`zstd.Decoder`s can be reused after being closed, so you can close them before\nplacing them in a sync.Pool, but doing so frees resources that we would want\nto keep until the decoder is no longer used.\n\nThese problems might be possible to work around with finalizers, but it is\ndifficult to confirm is working as expected, and could silently break\nwith internal changes in github.com/klauspost/compress/zstd.\n\n## Status\n\nThis code is not yet well tested, and the API may change at any time.\n\n## Usage\n\n### Encoding\n\n```Go\nvar encPool = zstdpool.NewEncoderPool()\n\nfunc compressStream(in io.Reader, out io.Writer) error {\n\tenc, err := encPool.Get(out)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer encPool.Put(enc)\n\n\t_, err = enc.ReadFrom(in)\n\treturn err\n}\n```\n\n### Decoding\n\n```Go\nvar decPool = zstdpool.NewDecoderPool()\n\nfunc decompressStream(in io.Reader, out io.Writer) error {\n\tdec, err := decPool.Get(in)\n\tif err != nil {\n\t\treturn err\n\t}\n\tdefer decPool.Put(dec)\n\n\t_, err = dec.WriteTo(out)\n\treturn err\n}\n```\n\n## Contributions\n\nContributions are always welcome.\n\n## License\n\nThis code is released under the [Apache 2.0 license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostynb%2Fzstdpool-freelist","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmostynb%2Fzstdpool-freelist","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmostynb%2Fzstdpool-freelist/lists"}