{"id":16209196,"url":"https://github.com/gilzoide/taskfactoryobject","last_synced_at":"2026-03-07T09:32:58.160Z","repository":{"id":70590788,"uuid":"482248356","full_name":"gilzoide/TaskFactoryObject","owner":"gilzoide","description":"TaskFactory Unity objects plus a collection of TaskSchedulers with optional limited concurrency","archived":false,"fork":false,"pushed_at":"2025-11-18T12:12:26.000Z","size":98,"stargazers_count":8,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-18T15:39:28.064Z","etag":null,"topics":["task-factory","task-scheduler","thread-pool","threading","unity"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gilzoide.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2022-04-16T12:29:48.000Z","updated_at":"2025-11-18T12:12:21.000Z","dependencies_parsed_at":"2024-10-27T20:25:52.071Z","dependency_job_id":"56f244fb-a3d3-4316-89a1-b9ff6bb13471","html_url":"https://github.com/gilzoide/TaskFactoryObject","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/gilzoide/TaskFactoryObject","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2FTaskFactoryObject","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2FTaskFactoryObject/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2FTaskFactoryObject/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2FTaskFactoryObject/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gilzoide","download_url":"https://codeload.github.com/gilzoide/TaskFactoryObject/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gilzoide%2FTaskFactoryObject/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30210847,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-07T09:02:10.694Z","status":"ssl_error","status_checked_at":"2026-03-07T09:02:08.429Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["task-factory","task-scheduler","thread-pool","threading","unity"],"created_at":"2024-10-10T10:28:34.716Z","updated_at":"2026-03-07T09:32:58.151Z","avatar_url":"https://github.com/gilzoide.png","language":"C#","readme":"# TaskFactoryObject\n[![openupm](https://img.shields.io/npm/v/com.gilzoide.taskfactory-object?label=openupm\u0026registry_uri=https://package.openupm.com)](https://openupm.com/packages/com.gilzoide.taskfactory-object/)\n\nConfigurable `MonoBehaviour` and `ScriptableObject` subclasses wrapping\n[TaskFactory](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskfactory?view=netstandard-2.0)\nobjects plus a collection of [TaskScheduler](https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.taskscheduler?view=netstandard-2.0)\nimplementations with limited concurrency. \n\n\n## Installing the package\nEither:\n- Use the [openupm registry](https://openupm.com/) and install this package using the [openupm-cli](https://github.com/openupm/openupm-cli):\n  ```\n  openupm add com.gilzoide.taskfactory-object\n  ```\n- Install via [Unity Package Manager](https://docs.unity3d.com/Manual/upm-ui-giturl.html) using this repository URL and tag:\n  ```\n  https://github.com/gilzoide/TaskFactoryObject.git#1.0.1\n  ```\n- Clone this repository directly inside your project's `Assets` or `Packages` folder.\n\n\n## TaskSchedulers\nThe [TaskSchedulers module](Runtime/TaskSchedulers/) comes with the following\nimplementations:\n\n- [SyncTaskScheduler](Runtime/TaskSchedulers/SyncTaskScheduler.cs): run tasks\n  in the current `SynchronizationContext`, which by default is Unity's Main\n  Thread. Default maximum concurrency is `int.MaxValue`, that is, process every\n  queued task in a single frame.\n- [ManagedThreadPoolTaskScheduler](Runtime/TaskSchedulers/ManagedThreadPoolTaskScheduler.cs):\n  run tasks in the [Managed Thread Pool](https://docs.microsoft.com/en-us/dotnet/standard/threading/the-managed-thread-pool).\n  Default maximum concurrency is `Environment.ProcessorCount`.\n- [OwnThreadsTaskScheduler](Runtime/TaskSchedulers/OwnThreadsTaskScheduler.cs):\n  creates its own threads and run tasks on them. Uses a\n  [SemaphoreSlim](https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphoreslim?view=netstandard-2.0)\n  for sleeping threads until there is work to be done. Threads can have their\n  name and background flag configured. Default maximum concurrency is\n  `Environment.ProcessorCount`.\n\n\n## TaskFactoryComponent and TaskFactoryScriptableObject\n[TaskFactoryComponent](Runtime/TaskFactoryComponent.cs) is a `MonoBehaviour`\nsubclass with configurations for creating `TaskFactory` and `TaskScheduler`\nobjects.\n[TaskFactoryScriptableObject](Runtime/TaskFactoryScriptableObject.cs) is its\n`ScriptableObject` counterpart, both work in the same way.\n\nTheir `Scheduler` property gets a configured `TaskScheduler` and their\n`Factory` property gets a configured `TaskFactory`. These are created on demand\nwhen accessing the properties.\n\nThe `TaskScheduler` and `TaskFactory`'s default `CancellationToken` are tied to\nthe lifetime of the objects and will be canceled automatically on\n`TaskFactoryComponent`'s `OnDestroy` and `TaskFactoryScriptableObject`'s\n`OnDisable` methods. When that happens, no more tasks can be scheduled and\npending ones will be dropped silently. One can also manually cancel them by\ncalling `DestroyFactory`. Accessing the `Scheduler` or `Factory` properties\nafterwards recreates them.\n\nIf `MaximumConcurrency` is 0 or a negative number, the created `TaskScheduler`\nwill use its own default maximum concurrency, which depends on the\nimplementation.\n\nUsage example:\n```cs\nusing System.Threading.Tasks;\nusing UnityEngine;\nusing Gilzoide.TaskFactoryObject;\n\npublic class SomeOtherScript : MonoBehaviour\n{\n    public TaskFactoryComponent FactoryComponent;\n    public TaskFactoryScriptableObject FactorySO;\n\n    async void Start()\n    {\n        // using TaskScheduler directly\n        Task task = new Task(() =\u003e\n        {\n            Debug.Log(\"This runs in the TaskScheduler configured by FactoryComponent!\");\n        });\n        task.Start(FactoryComponent.Scheduler);\n        await task;\n\n        // using the configured TaskFactory\n        await FactoryComponent.Factory.StartNew(() =\u003e\n        {\n            Debug.Log(\"This one too (FactoryComponent)!\");\n        });\n\n        // using TaskScheduler directly, this time from FactorySO\n        await Task.Delay(100).ContinueWith(_delayTask =\u003e\n        {\n            Debug.Log(\"This continuation runs in the TaskScheduler configured by FactorySO!\");\n        }, FactorySO.Scheduler);\n\n        Debug.Log(\"All done!\");\n    }\n}\n```\n\n![](Extras~/TaskFactoryComponent.png)\n![](Extras~/TaskFactoryScriptableObject.png)\n\n\n## TaskFactoryConfig\nThe [TaskFactoryConfig](Runtime/TaskFactoryConfig.cs) is a serializable class\nwith configurations for creating `TaskScheduler` and `TaskFactory` objects.\nThis is used by both `TaskFactoryComponent` and `TaskFactoryScriptableObject`.\n\nMethods:\n- `TaskScheduler CreateScheduler(CancellationToken cancellationToken = default)`:\n  creates a new `TaskScheduler` with the defined configuration.\n- `TaskFactory CreateFactory(CancellationToken cancellationToken = default)`:\n  creates a new `TaskFactory` with the defined configuration. A `TaskScheduler`\n  is also created via `CreateScheduler` and passed to it.\n- `TaskFactory CreateFactory(TaskScheduler taskScheduler, CancellationToken cancellationToken = default)`:\n  creates a new `TaskFactory` with the defined configuration, using a specific\n  scheduler object.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Ftaskfactoryobject","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgilzoide%2Ftaskfactoryobject","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgilzoide%2Ftaskfactoryobject/lists"}