{"id":44176536,"url":"https://github.com/lalinsky/zio","last_synced_at":"2026-05-31T06:02:11.576Z","repository":{"id":316614249,"uuid":"1057941251","full_name":"lalinsky/zio","owner":"lalinsky","description":"Async I/O framework for Zig","archived":false,"fork":false,"pushed_at":"2026-05-24T20:39:55.000Z","size":4014,"stargazers_count":493,"open_issues_count":19,"forks_count":22,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-05-24T22:23:11.278Z","etag":null,"topics":["async","coroutines","epoll","fibers","green-threads","io","io-uring","iocp","kqueue","networking","poll","zig","zig-package"],"latest_commit_sha":null,"homepage":"https://lalinsky.github.io/zio/","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lalinsky.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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"lalinsky"}},"created_at":"2025-09-16T12:12:46.000Z","updated_at":"2026-05-23T20:33:30.000Z","dependencies_parsed_at":"2025-10-15T19:13:37.607Z","dependency_job_id":"cf29359c-b072-4714-91f6-ac3f8ebf6872","html_url":"https://github.com/lalinsky/zio","commit_stats":null,"previous_names":["lalinsky/zio"],"tags_count":16,"template":false,"template_full_name":null,"purl":"pkg:github/lalinsky/zio","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalinsky%2Fzio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalinsky%2Fzio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalinsky%2Fzio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalinsky%2Fzio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lalinsky","download_url":"https://codeload.github.com/lalinsky/zio/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lalinsky%2Fzio/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33720897,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-05-31T02:00:06.040Z","response_time":95,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","coroutines","epoll","fibers","green-threads","io","io-uring","iocp","kqueue","networking","poll","zig","zig-package"],"created_at":"2026-02-09T13:15:33.454Z","updated_at":"2026-05-31T06:02:11.571Z","avatar_url":"https://github.com/lalinsky.png","language":"Zig","funding_links":["https://github.com/sponsors/lalinsky"],"categories":[],"sub_categories":[],"readme":"# ZIO - Async I/O framework for Zig\n\n[![CI](https://github.com/lalinsky/zio/actions/workflows/test.yml/badge.svg)](https://github.com/lalinsky/zio/actions/workflows/test.yml)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)\n[![Zig](https://img.shields.io/badge/zig-0.16.0-orange.svg)](https://ziglang.org/download/)\n[![Documentation](https://img.shields.io/badge/docs-online-green.svg)](https://lalinsky.github.io/zio/)\n\nThe project consists of a few high-level components:\n- Runtime for executing stackful coroutines (fibers, green threads) on one or more CPU threads.\n- Asynchronous I/O layer that makes it look like operations are blocking for easy state management, but using event-driven OS APIs under the hood.\n- Synchronization primitives that cooperate with this runtime.\n- Full implementation of the [`std.Io`] interface, so that you can use any Zig 0.16+ networking library.\n- Seamless integration with standard library interfaces, like [`std.Io.Reader`] and [`std.Io.Writer`].\n\nIt's similar to [goroutines] in Go, but with the pros and cons of being implemented in a language with manual memory management and without compiler support.\n\n\u003e The main branch is for Zig 0.16 . For Zig master (0.17+), use the [`zig-0.17`](https://github.com/lalinsky/zio/tree/zig-0.17) branch.\n\n[`std.Io`]: https://ziglang.org/documentation/0.16.0/std/#std.Io\n[`std.Io.Reader`]: https://ziglang.org/documentation/0.16.0/std/#std.Io.Reader\n[`std.Io.Writer`]: https://ziglang.org/documentation/0.16.0/std/#std.Io.Writer\n[goroutines]: https://en.wikipedia.org/wiki/Go_(programming_language)#Concurrency\n\n## Features\n\n- Support for Linux (`io_uring`, `epoll`), Windows (`iocp`), macOS (`kqueue`), most BSDs (`kqueue`), and many other systems (`poll`).\n- User-mode coroutine context switching for `x86_64`, `aarch64`, `arm`, `thumb`, `riscv32`, `riscv64`, `loongarch64` and `powerpc64` architectures.\n- Growable stacks for the coroutines implemented by auto-extending virtual memory reservations.\n- Single-threaded or multi-threaded coroutine scheduler.\n- Fully asynchronous network I/O on all systems. Supports TCP, UDP, Unix sockets, raw IP sockets, etc.\n- Fully asynchronous file I/O on Linux, partially asynchronous (read/write) on Windows. Using blocking syscalls in a thread pool on other systems.\n- Fully asynchronous DNS resolver on Linux, Windows and macOS. Using `getaddrinfo` in a thread pool on other systems.\n- Safe cancelation support for all operations.\n- Structured concurrency using task groups.\n- Synchronization primitives, including more advanced ones, like channels.\n- Low-level event loop access for integrating with existing C libraries.\n\n## Installation\n\n1) Add zio as a dependency in your `build.zig.zon`:\n\n```bash\nzig fetch --save \"git+https://github.com/lalinsky/zio#v0.13.0\"\n```\n\n2) In your `build.zig`, add the `zio` module as a dependency to your program:\n\n```zig\nconst zio = b.dependency(\"zio\", .{\n    .target = target,\n    .optimize = optimize,\n});\n\nexe.root_module.addImport(\"zio\", zio.module(\"zio\"));\n```\n\n## Usage\n\nThere are two main ways to use zio: the native API and the standard library's [`std.Io`] interface.\nFor most cases, prefer the `std.Io` interface, especially if you are writing a library.\nThe native API is more direct and has more features, but it ties you to the zio runtime.\n\nA minimal TCP echo server, using zio's native API:\n\n```zig\nconst std = @import(\"std\");\nconst zio = @import(\"zio\");\n\nfn handleClient(stream: zio.net.Stream) !void {\n    defer stream.close();\n\n    var read_buffer: [1024]u8 = undefined;\n    var reader = stream.reader(\u0026read_buffer);\n\n    var write_buffer: [1024]u8 = undefined;\n    var writer = stream.writer(\u0026write_buffer);\n\n    while (true) {\n        const line = reader.interface.takeDelimiterInclusive('\\n') catch |err| switch (err) {\n            error.EndOfStream =\u003e break,\n            else =\u003e return err,\n        };\n        try writer.interface.writeAll(line);\n        try writer.interface.flush();\n    }\n}\n\npub fn main() !void {\n    const rt = try zio.Runtime.init(std.heap.smp_allocator, .{});\n    defer rt.deinit();\n\n    const addr = try zio.net.IpAddress.parseIp4(\"127.0.0.1\", 8080);\n    const server = try addr.listen(.{});\n    defer server.close();\n\n    var group: zio.Group = .init;\n    defer group.cancel();\n\n    while (true) {\n        const stream = try server.accept(.{});\n        errdefer stream.close();\n        try group.spawn(handleClient, .{stream});\n    }\n}\n```\n\nThe same server written against the standard library's [`std.Io`] interface:\n\n```zig\nconst std = @import(\"std\");\nconst zio = @import(\"zio\");\n\nconst Io = std.Io;\n\nfn handleClient(io: Io, stream: Io.net.Stream) Io.Cancelable!void {\n    defer stream.close(io);\n\n    var read_buffer: [1024]u8 = undefined;\n    var reader = stream.reader(io, \u0026read_buffer);\n\n    var write_buffer: [1024]u8 = undefined;\n    var writer = stream.writer(io, \u0026write_buffer);\n\n    while (true) {\n        const line = reader.interface.takeDelimiterInclusive('\\n') catch |err| switch (err) {\n            error.EndOfStream =\u003e break,\n            error.ReadFailed =\u003e return if (reader.err.? == error.Canceled) error.Canceled else {},\n            else =\u003e return,\n        };\n        writer.interface.writeAll(line) catch return if (writer.err.? == error.Canceled) error.Canceled else {};\n        writer.interface.flush() catch return if (writer.err.? == error.Canceled) error.Canceled else {};\n    }\n}\n\npub fn main() !void {\n    const rt = try zio.Runtime.init(std.heap.smp_allocator, .{});\n    defer rt.deinit();\n    const io = rt.io();\n\n    const addr = try Io.net.IpAddress.parseIp4(\"127.0.0.1\", 8080);\n    var server = try addr.listen(io, .{});\n    defer server.deinit(io);\n\n    var group: Io.Group = .init;\n    defer group.cancel(io);\n\n    while (true) {\n        const stream = try server.accept(io);\n        errdefer stream.close(io);\n        try group.concurrent(io, handleClient, .{ io, stream });\n    }\n}\n```\n\nSee `examples/*.zig` for more examples.\n\n## Building\n\n```bash\n# Run tests\nzig build test\n\n# Build examples\nzig build examples\n```\n\n## Contributing\n\nSee [DEVELOPMENT.md](DEVELOPMENT.md).\n\n## License\n\nThis project is licensed under the [MIT license].\n\n[MIT license]: https://github.com/lalinsky/zio/blob/main/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flalinsky%2Fzio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flalinsky%2Fzio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flalinsky%2Fzio/lists"}