{"id":27858429,"url":"https://github.com/roboplc/atomic-timer","last_synced_at":"2025-05-04T14:10:05.802Z","repository":{"id":269346507,"uuid":"907132418","full_name":"roboplc/atomic-timer","owner":"roboplc","description":"Atomic timer for Rust","archived":false,"fork":false,"pushed_at":"2025-01-14T18:26:42.000Z","size":11,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-04T14:09:59.623Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/roboplc.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-12-22T22:31:13.000Z","updated_at":"2025-01-14T18:26:45.000Z","dependencies_parsed_at":"2024-12-22T22:47:25.321Z","dependency_job_id":"d1d9f319-1089-49c6-8878-772ec9fd9f8d","html_url":"https://github.com/roboplc/atomic-timer","commit_stats":null,"previous_names":["roboplc/atomic-timer"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Fatomic-timer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Fatomic-timer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Fatomic-timer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/roboplc%2Fatomic-timer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/roboplc","download_url":"https://codeload.github.com/roboplc/atomic-timer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252344577,"owners_count":21732981,"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":[],"created_at":"2025-05-04T14:10:04.943Z","updated_at":"2025-05-04T14:10:05.775Z","avatar_url":"https://github.com/roboplc.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch2\u003e\n  atomic-timer - an atomic timer for Rust\n  \u003ca href=\"https://crates.io/crates/atomic-timer\"\u003e\u003cimg alt=\"crates.io page\" src=\"https://img.shields.io/crates/v/atomic-timer.svg\"\u003e\u003c/img\u003e\u003c/a\u003e\n  \u003ca href=\"https://docs.rs/atomic-timer\"\u003e\u003cimg alt=\"docs.rs page\" src=\"https://docs.rs/atomic-timer/badge.svg\"\u003e\u003c/img\u003e\u003c/a\u003e\n  \u003ca href=\"https://github.com/roboplc/atomic-timer/actions/workflows/ci.yml\"\u003e\n    \u003cimg alt=\"GitHub Actions CI\" src=\"https://github.com/roboplc/atomic-timer/actions/workflows/ci.yml/badge.svg\"\u003e\u003c/img\u003e\n  \u003c/a\u003e\n\u003c/h2\u003e\n\nA passive timer object which can be manipulated atomically. Useful for\nautomation and robotics tasks.\n\nAtomic timer is a part of [RoboPLC](https://www.roboplc.com) project.\n\n## Usage example\n\n### Basic usage\n\n```rust\nuse atomic_timer::AtomicTimer;\nuse std::time::Duration;\n\nlet timer = AtomicTimer::new(Duration::from_secs(1));\nfor _ in 0..100 {\n    if timer.expired() {\n        println!(\"Timer expired\");\n        timer.reset(); // does not need to be mutable\n    } else {\n        println!(\"Elapsed: {:?}, remaining: {:?}\", timer.elapsed(), timer.remaining());\n    }\n    // do some work\n}\n```\n\n### Multi-threaded usage\n\n```rust\nuse atomic_timer::AtomicTimer;\nuse std::sync::Arc;\nuse std::time::Duration;\n\nlet timer = Arc::new(AtomicTimer::new(Duration::from_secs(1)));\nfor _ in 0..10 {\n    let timer = timer.clone();\n    std::thread::spawn(move || {\n        for _ in 0..100 {\n            if timer.reset_if_expired() {\n                println!(\"Timer expired\");\n                // react to the timer expiration\n                // guaranteed to be true only for one thread\n            }\n            // do some other work\n        }\n    });\n}\n```\n\n## Serialization / deserialization\n\nAtomic timer objects can be safely serialized and de-serialized (requires\n`serde` feature).\n\nWhen a timer is de-serialized, it keeps its state (elapsed/remaining time),\ndespite the system monotonic clock difference.\n\n## MSRV\n\n1.68.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froboplc%2Fatomic-timer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Froboplc%2Fatomic-timer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Froboplc%2Fatomic-timer/lists"}