{"id":13632627,"url":"https://github.com/smol-rs/polling","last_synced_at":"2025-05-13T20:15:27.209Z","repository":{"id":47150723,"uuid":"285573174","full_name":"smol-rs/polling","owner":"smol-rs","description":"Portable interface to epoll, kqueue, event ports, and wepoll","archived":false,"fork":false,"pushed_at":"2025-05-05T18:01:11.000Z","size":389,"stargazers_count":629,"open_issues_count":25,"forks_count":75,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-05-12T23:04:47.451Z","etag":null,"topics":["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/smol-rs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2020-08-06T13:02:49.000Z","updated_at":"2025-05-12T02:14:27.000Z","dependencies_parsed_at":"2025-03-30T19:00:28.461Z","dependency_job_id":"5c7526dd-c8fa-4a3c-886a-2803bdc5f50e","html_url":"https://github.com/smol-rs/polling","commit_stats":{"total_commits":242,"total_committers":30,"mean_commits":8.066666666666666,"dds":0.7066115702479339,"last_synced_commit":"033e3a80e97810be25a20eaaa29e80c610201c7b"},"previous_names":[],"tags_count":42,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fpolling","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fpolling/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fpolling/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smol-rs%2Fpolling/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smol-rs","download_url":"https://codeload.github.com/smol-rs/polling/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254020638,"owners_count":22000755,"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":["rust"],"created_at":"2024-08-01T22:03:09.259Z","updated_at":"2025-05-13T20:15:27.185Z","avatar_url":"https://github.com/smol-rs.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"# polling\n\n[![Build](https://github.com/smol-rs/polling/actions/workflows/ci.yml/badge.svg)](\nhttps://github.com/smol-rs/polling/actions)\n[![License](https://img.shields.io/badge/license-Apache--2.0_OR_MIT-blue.svg)](\nhttps://github.com/smol-rs/polling)\n[![Cargo](https://img.shields.io/crates/v/polling.svg)](\nhttps://crates.io/crates/polling)\n[![Documentation](https://docs.rs/polling/badge.svg)](\nhttps://docs.rs/polling)\n\nPortable interface to epoll, kqueue, event ports, and IOCP.\n\nSupported platforms:\n- [epoll](https://en.wikipedia.org/wiki/Epoll): Linux, Android, RedoxOS\n- [kqueue](https://en.wikipedia.org/wiki/Kqueue): macOS, iOS, tvOS, watchOS, visionOS, FreeBSD, NetBSD, OpenBSD,\n  DragonFly BSD\n- [event ports](https://illumos.org/man/port_create): illumos, Solaris\n- [poll](https://en.wikipedia.org/wiki/Poll_(Unix)): VxWorks, Fuchsia, HermitOS, other Unix systems\n- [IOCP](https://learn.microsoft.com/en-us/windows/win32/fileio/i-o-completion-ports): Windows, Wine (version 7.13+)\n\nBy default, polling is done in oneshot mode, which means interest in I/O events needs to\nbe re-enabled after an event is delivered if we're interested in the next event of the same\nkind. However, level and edge triggered modes are also available for certain operating\nsystems. See the documentation of the [`PollMode`] type for more information.\n\nOnly one thread can be waiting for I/O events at a time.\n\n[`PollMode`]: https://docs.rs/polling/latest/polling/enum.PollMode.html\n\n## Examples\n\n```rust,no_run\nuse polling::{Event, Poller};\nuse std::net::TcpListener;\n\n// Create a TCP listener.\nlet socket = TcpListener::bind(\"127.0.0.1:8000\")?;\nsocket.set_nonblocking(true)?;\nlet key = 7; // Arbitrary key identifying the socket.\n\n// Create a poller and register interest in readability on the socket.\nlet poller = Poller::new()?;\npoller.add(\u0026socket, Event::readable(key))?;\n\n// The event loop.\nlet mut events = Vec::new();\nloop {\n    // Wait for at least one I/O event.\n    events.clear();\n    poller.wait(\u0026mut events, None)?;\n\n    for ev in \u0026events {\n        if ev.key == key {\n            // Perform a non-blocking accept operation.\n            socket.accept()?;\n            // Set interest in the next readability event.\n            poller.modify(\u0026socket, Event::readable(key))?;\n        }\n    }\n}\n```\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/license/mit/)\n\nat your option.\n\n#### Contribution\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be\ndual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Fpolling","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmol-rs%2Fpolling","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmol-rs%2Fpolling/lists"}