{"id":23363014,"url":"https://github.com/s2-streamstore/tokio-muxt","last_synced_at":"2026-02-01T00:27:45.987Z","repository":{"id":247999890,"uuid":"827469823","full_name":"s2-streamstore/tokio-muxt","owner":"s2-streamstore","description":"Timer for a limited set of events that multiplexes over a single tokio Sleep instance.","archived":false,"fork":false,"pushed_at":"2024-12-09T21:21:13.000Z","size":31,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T10:17:44.071Z","etag":null,"topics":["async","deadline","multiplexing","rust","sleep","timer","tokio"],"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/s2-streamstore.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":"2024-07-11T17:52:28.000Z","updated_at":"2024-12-21T23:35:06.000Z","dependencies_parsed_at":"2024-07-31T05:46:32.996Z","dependency_job_id":"6a17b0e8-8fd0-4126-b6fc-ce4023dd68f5","html_url":"https://github.com/s2-streamstore/tokio-muxt","commit_stats":null,"previous_names":["shikhar/tokio-mux-sleep","s2-streamstore/tokio-muxt"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2-streamstore%2Ftokio-muxt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2-streamstore%2Ftokio-muxt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2-streamstore%2Ftokio-muxt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/s2-streamstore%2Ftokio-muxt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/s2-streamstore","download_url":"https://codeload.github.com/s2-streamstore/tokio-muxt/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248217057,"owners_count":21066633,"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","deadline","multiplexing","rust","sleep","timer","tokio"],"created_at":"2024-12-21T12:36:03.379Z","updated_at":"2026-02-01T00:27:45.981Z","avatar_url":"https://github.com/s2-streamstore.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# tokio-muxt\n\nA tiny timer that multiplexes a small set of event deadlines over a single `tokio::time::Sleep`.\n\n`MuxTimer` is useful when you have a fixed, small set of event types and want one async timer that wakes for the next event, returning the event's ordinal and its deadline.\n\n## Features\n\n- One `tokio::time::Sleep` instance for many events.\n- Coalesce repeated deadlines for the same event to the earliest or latest one.\n- Stack-allocated storage with a const-generic capacity.\n- Simple `Future` interface that yields `(ordinal, deadline)`.\n\n## Example\n\n```rust\nuse std::time::Duration;\n\nuse tokio::pin;\nuse tokio::time::Instant;\n\nuse tokio_muxt::{CoalesceMode, MuxTimer};\n\nconst EVENT_A: usize = 0;\nconst EVENT_B: usize = 1;\n\n#[tokio::main]\nasync fn main() {\n    let timer: MuxTimer\u003c2\u003e = MuxTimer::default();\n    pin!(timer);\n\n    let start = Instant::now();\n\n    timer\n        .as_mut()\n        .fire_after(EVENT_A, Duration::from_millis(50), CoalesceMode::Earliest);\n    timer\n        .as_mut()\n        .fire_after(EVENT_B, Duration::from_millis(20), CoalesceMode::Earliest);\n\n    let (event, deadline) = timer.as_mut().await;\n    println!(\"first event = {event}, at +{:?}\", deadline.duration_since(start));\n}\n```\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs2-streamstore%2Ftokio-muxt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fs2-streamstore%2Ftokio-muxt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fs2-streamstore%2Ftokio-muxt/lists"}