{"id":13507587,"url":"https://github.com/PSPDFKit-labs/sidetask","last_synced_at":"2025-03-30T09:32:58.200Z","repository":{"id":21944052,"uuid":"25268543","full_name":"PSPDFKit-labs/sidetask","owner":"PSPDFKit-labs","description":":awesome = Elixir's Task ++ Basho's sidejob library","archived":false,"fork":false,"pushed_at":"2017-06-12T18:01:06.000Z","size":129,"stargazers_count":72,"open_issues_count":0,"forks_count":5,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-26T02:37:07.084Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/PSPDFKit-labs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-10-15T18:48:37.000Z","updated_at":"2024-05-08T07:09:00.000Z","dependencies_parsed_at":"2022-08-17T23:45:29.686Z","dependency_job_id":null,"html_url":"https://github.com/PSPDFKit-labs/sidetask","commit_stats":null,"previous_names":["msch/sidetask"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit-labs%2Fsidetask","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit-labs%2Fsidetask/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit-labs%2Fsidetask/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PSPDFKit-labs%2Fsidetask/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PSPDFKit-labs","download_url":"https://codeload.github.com/PSPDFKit-labs/sidetask/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246301963,"owners_count":20755512,"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-08-01T02:00:36.601Z","updated_at":"2025-03-30T09:32:57.945Z","avatar_url":"https://github.com/PSPDFKit-labs.png","language":"Elixir","readme":"SideTask\n========\n\n[![Build Status](https://travis-ci.org/PSPDFKit-labs/sidetask.svg)](https://travis-ci.org/PSPDFKit-labs/sidetask)\n\nSideTask is an alternative to Elixir's\n[Task.Supervisor](http://elixir-lang.org/docs/stable/elixir/Task.Supervisor.html) that uses Basho's\n[sidejob](https://github.com/basho/sidejob) library for better parallelism and to support capacity\nlimiting of [Tasks](http://elixir-lang.org/docs/stable/elixir/Task.html).\n\nElixir's `Task.Supervisor` is implemented as a single `:simple_one_for_one` supervisor with the\nindividual `Task`s as children. This means starting a new task has to go through this single\nsupervisor. Furthermore there is no limit to the number of workers that can be running at the same\ntime.\n\nBasho's sidejob library spawns multiple supervisors (one for each scheduler by default) and\nuses ETS tables to keep track of the number of workers, thereby making it possible to start\nworkers in parallel while also putting an upper bound on the number of running workers.\n\nSideTask provides an API similar to `Task.Supervisor`, with the addition that all calls that\nstart a new task require a sidejob resource as argument and can return `{:error, :overload}`.\n\nConvenience functions for adding and deleting sidejob resources are provided.\n\n## Example 1\n\n```elixir\nSideTask.add_resource(:example1, 50)\npotential_tasks = for i \u003c- 1..100 do\n  case SideTask.async(:example1, fn -\u003e :timer.sleep(1000); i end) do\n    {:ok, task} -\u003e\n      IO.puts \"Task #{i} created\"\n      task\n    {:error, :overload} -\u003e\n      IO.puts \"Task #{i} not created, overloaded\"\n      nil\n  end\nend\nIO.inspect for task = %Task{} \u003c- potential_tasks, do: Task.await(task)\n```\n\n## Example 2\n\n```elixir\n# Erlang spawns one scheduler per CPU core by default\nschedulers = :erlang.system_info(:schedulers)\nSideTask.add_resource(:example2, schedulers * 2)\nfor scheduler \u003c- 1..schedulers do\n  spawn_link fn -\u003e\n    for i \u003c- Stream.iterate(0, \u0026(\u00261+1)) do\n      SideTask.start_child :example2, fn -\u003e\n        :timer.sleep(250);\n        IO.inspect scheduler: scheduler, count: i\n      end\n    end\n  end\nend\n```\n\n![Observer while running example 2](https://raw.githubusercontent.com/MSch/sidetask/gh-pages/observer.png)\n\n## License\n\nThis software is licensed under [the MIT license](LICENSE).\n\n## About\n\n\u003ca href=\"https://pspdfkit.com/\"\u003e\n  \u003cimg src=\"https://avatars2.githubusercontent.com/u/1527679?v=3\u0026s=200\" height=\"80\" /\u003e\n\u003c/a\u003e\n\nThis project is maintained and funded by [PSPDFKit](https://pspdfkit.com/).\n\nSee [our other open source projects](https://github.com/PSPDFKit-labs), read [our blog](https://pspdfkit.com/blog/) or say hello on Twitter ([@PSPDFKit](https://twitter.com/pspdfkit)).\n","funding_links":[],"categories":["Cloud Infrastructure and Management"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPSPDFKit-labs%2Fsidetask","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FPSPDFKit-labs%2Fsidetask","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FPSPDFKit-labs%2Fsidetask/lists"}