{"id":19058005,"url":"https://github.com/bve-reborn/switchyard","last_synced_at":"2025-04-04T20:03:29.401Z","repository":{"id":44682805,"uuid":"289981322","full_name":"BVE-Reborn/switchyard","owner":"BVE-Reborn","description":"Real-time compute-focused async executor with job pools, thread-local data, and priorities.","archived":false,"fork":false,"pushed_at":"2024-12-29T02:26:05.000Z","size":112,"stargazers_count":66,"open_issues_count":8,"forks_count":5,"subscribers_count":3,"default_branch":"trunk","last_synced_at":"2025-03-21T18:05:32.746Z","etag":null,"topics":["async-await","executor","rust"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/BVE-Reborn.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.APACHE","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},"funding":{"github":"cwfitzgerald"}},"created_at":"2020-08-24T16:31:17.000Z","updated_at":"2025-03-07T13:42:30.000Z","dependencies_parsed_at":"2024-12-29T03:20:56.049Z","dependency_job_id":"6a5884c6-296a-4737-bc44-0b537bdce5c6","html_url":"https://github.com/BVE-Reborn/switchyard","commit_stats":{"total_commits":91,"total_committers":4,"mean_commits":22.75,"dds":0.08791208791208793,"last_synced_commit":"82d06ea6d48306983d0a1322dea2953dd7b9b2e2"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BVE-Reborn%2Fswitchyard","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BVE-Reborn%2Fswitchyard/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BVE-Reborn%2Fswitchyard/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BVE-Reborn%2Fswitchyard/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BVE-Reborn","download_url":"https://codeload.github.com/BVE-Reborn/switchyard/tar.gz/refs/heads/trunk","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246085591,"owners_count":20721210,"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":["async-await","executor","rust"],"created_at":"2024-11-09T00:00:21.628Z","updated_at":"2025-03-28T19:03:44.809Z","avatar_url":"https://github.com/BVE-Reborn.png","language":"Rust","funding_links":["https://github.com/sponsors/cwfitzgerald"],"categories":[],"sub_categories":[],"readme":"# switchyard\n\n![GitHub Workflow Status](https://img.shields.io/github/workflow/status/BVE-Reborn/switchyard/CI)\n[![Crates.io](https://img.shields.io/crates/v/switchyard)](https://crates.io/crates/switchyard)\n[![Documentation](https://docs.rs/switchyard/badge.svg)](https://docs.rs/switchyard)\n![License](https://img.shields.io/crates/l/switchyard)\n\nReal-time compute-focused async executor with job pools, thread-local data, and priorities.\n\n## Example\n\n```rust\nuse switchyard::Switchyard;\nuse switchyard::threads::{thread_info, one_to_one};\n// Create a new switchyard without thread local data\nlet yard = Switchyard::new(one_to_one(thread_info(), Some(\"thread-name\")), ||()).unwrap();\n\n// Spawn a task on priority 10 and get a JoinHandle\nlet handle = yard.spawn(10, async move { 5 + 5 });\n// Spawn a lower priority task\nlet handle2 = yard.spawn(0, async move { 2 + 2 });\n\n// Wait on the results\nassert_eq!(handle.await + handle2.await, 14);\n```\n\n## How Switchyard is Different\n\nSwitchyard is different from other existing async executors, focusing on situations where\nprecise control of threads and execution order is needed. One such situation is using\ntask parallelism to parallelize a compute workload.\n\n### Priorites\n\nEach task has a priority and tasks are ran in order from high priority to low priority.\n\n```rust\n// Spawn task with lowest priority.\nyard.spawn(0, async move { /* ... */ });\n// Spawn task with higher priority. If both tasks are waiting, this one will run first.\nyard.spawn(10, async move { /* ... */ });\n```\n\n### Thread Local Data\n\nEach yard has some thread local data that can be accessed using [`spawn_local`](Switchyard::spawn_local).\nBoth the thread local data and the future generated by the async function passed to [`spawn_local`](Switchyard::spawn_local)\nmay be `!Send` and `!Sync`. The future will only be resumed on the thread that created it.\n\n```rust\n// Create yard with thread local data. The data is !Sync.\nlet yard = Switchyard::new(one_to_one(thread_info(), Some(\"thread-name\")), || Cell::new(42)).unwrap();\n\n// Spawn task that uses thread local data. Each running thread will get their own copy.\nyard.spawn_local(0, |data| async move { data.set(10) });\n```\n\n## MSRV\n1.51\n\nFuture MSRV bumps will be breaking changes.\n\nLicense: MIT OR Apache-2.0 OR Zlib\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbve-reborn%2Fswitchyard","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbve-reborn%2Fswitchyard","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbve-reborn%2Fswitchyard/lists"}