{"id":17108473,"url":"https://github.com/g-andrade/taskforce","last_synced_at":"2025-04-13T02:45:05.862Z","repository":{"id":29817329,"uuid":"33361803","full_name":"g-andrade/taskforce","owner":"g-andrade","description":"On-demand worker pools for parallelizable tasks","archived":false,"fork":false,"pushed_at":"2022-04-09T19:14:40.000Z","size":68,"stargazers_count":43,"open_issues_count":1,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-13T02:44:32.770Z","etag":null,"topics":["erlang","parallelization","worker-pool"],"latest_commit_sha":null,"homepage":"","language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"1C-Romania/bms-doc","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/g-andrade.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":"2015-04-03T12:14:17.000Z","updated_at":"2024-05-19T16:36:05.000Z","dependencies_parsed_at":"2022-09-02T11:01:15.694Z","dependency_job_id":null,"html_url":"https://github.com/g-andrade/taskforce","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ftaskforce","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ftaskforce/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ftaskforce/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/g-andrade%2Ftaskforce/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/g-andrade","download_url":"https://codeload.github.com/g-andrade/taskforce/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248657855,"owners_count":21140843,"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":["erlang","parallelization","worker-pool"],"created_at":"2024-10-14T16:05:27.305Z","updated_at":"2025-04-13T02:45:05.834Z","avatar_url":"https://github.com/g-andrade.png","language":"Erlang","readme":"\n\n# taskforce #\n\n**This library is not under active maintenance; if you'd like to perform\nmaintenance yourself, feel free to open an issue requesting access.**\n\nCopyright (c) 2015-2022 Guilherme Andrade\n\n__Version:__ 1.2.3\n\n__Authors:__ Guilherme Andrade ([`g@gandrade.net`](mailto:g@gandrade.net)).\n\n`taskforce` allows you to parallelise arbitrary tasks in a controlled way.\n\n\n---------\n\n\n### \u003ca name=\"Creating_tasks\"\u003eCreating tasks\u003c/a\u003e ###\n\n\n```erlang\n\nTasks = #{ some_task =\u003e taskforce:task(fun work/0, Args, #{ timeout =\u003e 2000 }),\n           similar_task =\u003e taskforce:task(fun work/0, Args123, #{ timeout =\u003e 2500 }),\n           other_task =\u003e taskforce:task(fun other_work/1, OtherArgs, #{ timeout =\u003e 500 }) }.\n\n```\n\n\n### \u003ca name=\"Executing_tasks\"\u003eExecuting tasks\u003c/a\u003e ###\n\n\n```erlang\n\n#{ completed := Completed } = taskforce:execute(Tasks),\nSomeTaskResult = maps:get(some_task, Completed),\nSimilarTaskResult = maps:get(similar_task, Completed),\nOtherTaskResult = maps:get(other_task, Completed).\n\n```\n\n\n### \u003ca name=\"Finely_tuning_execution\"\u003eFinely tuning execution\u003c/a\u003e ###\n\n\n```erlang\n\nExecutionOptions = #{ max_workers =\u003e 8, timeout =\u003e 5000 },\n#{ completed := Completed } = taskforce:execute(Tasks, ExecutionOptions),\n% ...\n\n```\n\n\n### \u003ca name=\"Individual_task_timeouts\"\u003eIndividual task timeouts\u003c/a\u003e ###\n\n\n```erlang\n\n% ...\n#{ individual_timeouts := IndividualTimeouts } = taskforce:execute(Tasks),\n(length(IndividualTimeouts) \u003e 0\n andalso io:format(\"oh noes! tasks with ids ~p timed-out\",\n                   [IndividualTimeouts]))\n\n```\n\n\n### \u003ca name=\"Global_execution_timeouts\"\u003eGlobal execution timeouts\u003c/a\u003e ###\n\n\n```erlang\n\n% ...\n#{ global_timeouts := GlobalTimeouts } = taskforce:execute(Tasks),\n(length(GlobalTimeouts) \u003e 0\n andalso io:format(\"execution ran out of time; tasks with ids ~p timed-out\",\n                   [GlobalTimeouts]))\n\n```\n\n\n### \u003ca name=\"Full_example\"\u003eFull example\u003c/a\u003e ###\n\n\n```erlang\n\n%\n% Calculate first 200 prime numbers using 4 processes,\n% with a timeout of 2s per individual calculation and 10s\n% for the whole batch.\n%\nNrOfPrimes = 200,\nTasks =\n    maps:from_list(\n        [{Nth, taskforce:task(fun fancy_lib:find_nth_prime/1,\n                              [Nth], #{ timeout =\u003e 2000 })}\n         || Nth \u003c- lists:seq(1, NrOfPrimes)]),\n\nExecutionOptions =\n    #{ % default is the sum of all individual task timeouts\n       timeout =\u003e 10000,\n\n       % default is number of active schedulers\n       max_workers =\u003e 4 },\n\n#{ completed := NthPrimes } = taskforce:execute(Tasks, ExecutionOptions),\nio:format(\"200th prime is: ~p~n\", [maps:get(200, NthPrimes)]).\n\n```\nAlso in `examples/`.\n\n\n## Modules ##\n\n\n\u003ctable width=\"100%\" border=\"0\" summary=\"list of modules\"\u003e\n\u003ctr\u003e\u003ctd\u003e\u003ca href=\"https://github.com/g-andrade/taskforce/blob/master/doc/taskforce.md\" class=\"module\"\u003etaskforce\u003c/a\u003e\u003c/td\u003e\u003c/tr\u003e\u003c/table\u003e\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-andrade%2Ftaskforce","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fg-andrade%2Ftaskforce","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fg-andrade%2Ftaskforce/lists"}