{"id":16244076,"url":"https://github.com/doumanash/async-timer","last_synced_at":"2025-04-03T09:11:40.293Z","repository":{"id":45212489,"uuid":"182324562","full_name":"DoumanAsh/async-timer","owner":"DoumanAsh","description":"Timer facilities for Rust's async story","archived":false,"fork":false,"pushed_at":"2024-09-29T00:29:30.000Z","size":166,"stargazers_count":52,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-11T14:17:23.361Z","etag":null,"topics":["async","rust","timer"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DoumanAsh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-19T20:54:21.000Z","updated_at":"2024-09-29T00:29:34.000Z","dependencies_parsed_at":"2024-01-22T00:22:56.282Z","dependency_job_id":"f1a04815-7145-4c02-ba94-a849859ab257","html_url":"https://github.com/DoumanAsh/async-timer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoumanAsh%2Fasync-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoumanAsh%2Fasync-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoumanAsh%2Fasync-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DoumanAsh%2Fasync-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DoumanAsh","download_url":"https://codeload.github.com/DoumanAsh/async-timer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246970322,"owners_count":20862509,"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","rust","timer"],"created_at":"2024-10-10T14:17:43.943Z","updated_at":"2025-04-03T09:11:40.268Z","avatar_url":"https://github.com/DoumanAsh.png","language":"Rust","readme":"# async-timer\n\n![Rust](https://github.com/DoumanAsh/async-timer/workflows/Rust/badge.svg?branch=master)\n[![Crates.io](https://img.shields.io/crates/v/async-timer.svg)](https://crates.io/crates/async-timer)\n[![Documentation](https://docs.rs/async-timer/badge.svg)](https://docs.rs/crate/async-timer/)\n[![dependency status](https://deps.rs/crate/async-timer/1.0.0-beta.13/status.svg)](https://deps.rs/crate/async-timer)\n\nTimer facilities for Rust's async story\n\n## Accuracy\n\nRegular timers that do not rely on async event loop tend to be on par with user space timers\nlike in `tokio`.\nIf that's not suitable for you you should enable event loop based timers which in most cases\ngive you the most accurate timers possible on unix platforms (See features.)\n\n## Features\n\n- `tokio1` - Enables event loop based timers using tokio, providing higher resolution timers on unix platforms.\n- `c_wrapper` - Uses C shim to create bindings to platform API, which may be more reliable than `libc`.\n- `std` - Enables usage of std types (e.g. Error)\n\n## Examples\n\n### Timed\n\n```rust\nasync fn job() {\n}\n\nasync fn do_job() {\n    let work = unsafe {\n        async_timer::Timed::platform_new_unchecked(job(), core::time::Duration::from_secs(1))\n    };\n\n    match work.await {\n        Ok(_) =\u003e println!(\"I'm done!\"),\n        //You can retry by polling `expired`\n        Err(expired) =\u003e println!(\"Job expired: {}\", expired),\n    }\n}\n```\n\n### Interval\n\n```rust\nasync fn job() {\n}\n\nasync fn do_a_while() {\n    let mut times: u8 = 0;\n    let mut interval = async_timer::Interval::platform_new(core::time::Duration::from_secs(1));\n\n    while times \u003c 5 {\n        job().await;\n        interval.wait().await;\n        times += 1;\n    }\n}\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoumanash%2Fasync-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdoumanash%2Fasync-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdoumanash%2Fasync-timer/lists"}