{"id":13637290,"url":"https://github.com/iddm/thread-priority","last_synced_at":"2025-05-15T09:04:18.794Z","repository":{"id":22056036,"uuid":"95105368","full_name":"iddm/thread-priority","owner":"iddm","description":"A simple Cross-platform thread schedule and priority library for rust.","archived":false,"fork":false,"pushed_at":"2024-11-07T09:25:20.000Z","size":155,"stargazers_count":110,"open_issues_count":12,"forks_count":20,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-11-16T11:32:29.339Z","etag":null,"topics":["priority","pthread","rust","rust-library","schedule","thread"],"latest_commit_sha":null,"homepage":"","language":"Rust","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/iddm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","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":"iddm"}},"created_at":"2017-06-22T10:47:33.000Z","updated_at":"2024-11-11T10:09:56.000Z","dependencies_parsed_at":"2023-12-05T17:21:11.796Z","dependency_job_id":"0cdee16b-be0b-4337-86f8-7e1d3d42cb6e","html_url":"https://github.com/iddm/thread-priority","commit_stats":{"total_commits":129,"total_committers":11,"mean_commits":"11.727272727272727","dds":0.2790697674418605,"last_synced_commit":"74cf570b36bb12d0dc3ea2d406d21569516aff96"},"previous_names":["iddm/thread-priority","vityafx/thread-priority"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fthread-priority","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fthread-priority/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fthread-priority/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iddm%2Fthread-priority/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iddm","download_url":"https://codeload.github.com/iddm/thread-priority/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248890669,"owners_count":21178483,"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":["priority","pthread","rust","rust-library","schedule","thread"],"created_at":"2024-08-02T00:01:14.669Z","updated_at":"2025-04-14T13:47:22.987Z","avatar_url":"https://github.com/iddm.png","language":"Rust","readme":"# thread-priority\n[![CI](https://github.com/iddm/thread-priority/actions/workflows/ci.yml/badge.svg)](https://github.com/iddm/thread-priority/actions/workflows/ci.yml) [![Crates](https://img.shields.io/crates/v/thread-priority.svg)](https://crates.io/crates/thread-priority) [![Docs](https://docs.rs/thread-priority/badge.svg)](https://docs.rs/thread-priority) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)\n\n\nA simple library to control thread schedule policies and thread priority.\n\nIf your operating system isn't yet supported, please, create an issue.\n\n## Minimal Rust Compiler Version\nIs `1.67`. If you need any help making it possible to compile with `1.56` please reach out, it\nshould be possible by just downgrading the `rstest` version to `0.17` or lower (the code is\ncompatible).\n\n## Supported platforms\n- Linux\n- Android\n- DragonFly\n- FreeBSD\n- OpenBSD\n- NetBSD\n- macOS\n- iOS\n- Windows\n\n## Examples\n\n### Minimal cross-platform examples\nSetting current thread's priority to minimum:\n\n```rust,no_run\nuse thread_priority::*;\n\nfn main() {\n    assert!(set_current_thread_priority(ThreadPriority::Min).is_ok());\n}\n```\n\nThe same as above but using a specific value:\n\n```rust,no_run\nuse thread_priority::*;\nuse std::convert::TryInto;\n\nfn main() {\n    // The lower the number the lower the priority.\n    assert!(set_current_thread_priority(ThreadPriority::Crossplatform(0.try_into().unwrap())).is_ok());\n}\n```\n\n### Windows-specific examples\nSet the thread priority to the lowest possible value:\n\n```rust,no_run\nuse thread_priority::*;\n\nfn main() {\n    // The lower the number the lower the priority.\n    assert!(set_current_thread_priority(ThreadPriority::Os(WinAPIThreadPriority::Lowest.into())).is_ok());\n}\n```\n\nSet the ideal processor for the new thread:\n\n```rust,no_run\nuse thread_priority::*;\n\nfn main() {\n    std::thread::spawn(|| {\n        set_thread_ideal_processor(thread_native_id(), 0);\n        println!(\"Hello world!\");\n    });\n}\n```\n\n\n### Building a thread using the ThreadBuilderExt trait\n\n```rust,no_run\nuse thread_priority::*;\nuse thread_priority::ThreadBuilderExt;\n\nlet thread = std::thread::Builder::new()\n    .name(\"MyNewThread\".to_owned())\n    .spawn_with_priority(ThreadPriority::Max, |result| {\n        // This is printed out from within the spawned thread.\n        println!(\"Set priority result: {:?}\", result);\n        assert!(result.is_ok());\n}).unwrap();\nthread.join();\n```\n\n### Building a thread using the ThreadBuilder.\n\n```rust,no_run\nuse thread_priority::*;\n\nlet thread = ThreadBuilder::default()\n    .name(\"MyThread\")\n    .priority(ThreadPriority::Max)\n    .spawn(|result| {\n        // This is printed out from within the spawned thread.\n        println!(\"Set priority result: {:?}\", result);\n        assert!(result.is_ok());\n}).unwrap();\nthread.join();\n\n// Another example where we don't care about the priority having been set.\nlet thread = ThreadBuilder::default()\n    .name(\"MyThread\")\n    .priority(ThreadPriority::Max)\n    .spawn_careless(|| {\n        // This is printed out from within the spawned thread.\n        println!(\"We don't care about the priority result.\");\n}).unwrap();\nthread.join();\n```\n\n### Using ThreadExt trait on the current thread\n\n```rust,no_run\nuse thread_priority::*;\n\nassert!(std::thread::current().get_priority().is_ok());\nprintln!(\"This thread's native id is: {:?}\", std::thread::current().get_native_id());\n```\n\n## License\nThis project is [licensed under the MIT license](https://github.com/iddm/thread-priority/blob/master/LICENSE).\n","funding_links":["https://github.com/sponsors/iddm"],"categories":["Libraries"],"sub_categories":["Platform specific"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Fthread-priority","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiddm%2Fthread-priority","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiddm%2Fthread-priority/lists"}