{"id":13415534,"url":"https://github.com/pallas/ioucontext","last_synced_at":"2026-04-16T17:07:42.522Z","repository":{"id":212888165,"uuid":"731773936","full_name":"pallas/ioucontext","owner":"pallas","description":"A coöperative multitasking framework based on `liburing` and `libucontext`","archived":false,"fork":false,"pushed_at":"2024-02-14T18:27:38.000Z","size":243,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-07-31T21:53:55.216Z","etag":null,"topics":["c-ares","cooperative-multitasking","io-uring","libucontext","liburing","linux","reactor-pattern","rfc862","rustls","ucontext"],"latest_commit_sha":null,"homepage":"","language":"C","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/pallas.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":"2023-12-14T21:07:35.000Z","updated_at":"2024-02-21T04:59:17.000Z","dependencies_parsed_at":"2024-01-01T23:27:45.536Z","dependency_job_id":"e2cae43d-5940-4914-85d3-ac8c012831cf","html_url":"https://github.com/pallas/ioucontext","commit_stats":null,"previous_names":["pallas/ioucontext"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallas%2Fioucontext","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallas%2Fioucontext/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallas%2Fioucontext/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pallas%2Fioucontext/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pallas","download_url":"https://codeload.github.com/pallas/ioucontext/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232417226,"owners_count":18519675,"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":["c-ares","cooperative-multitasking","io-uring","libucontext","liburing","linux","reactor-pattern","rfc862","rustls","ucontext"],"created_at":"2024-07-30T21:00:50.077Z","updated_at":"2026-04-16T17:07:42.512Z","avatar_url":"https://github.com/pallas.png","language":"C","funding_links":[],"categories":["Libraries","C/C++"],"sub_categories":["C"],"readme":"# ioucontext\n\n`ioucontext` is a coöperative multitasking framework built on top of\n[liburing](https://github.com/axboe/liburing),\n[libucontext](https://github.com/kaniini/libucontext),\n[c-ares](https://github.com/c-ares/c-ares), \u0026\n[rustls](https://github.com/rustls/rustls-ffi).\nIt is the spiritual successor to\n[liboco](https://github.com/pallas/liboco).\n\n## Design\nA thread-local `reactor` manages asynchronous `operations` submitted by one\nor more `fiber`s, each with a built-in `stack`.  When invoked via\n`reactor_run`, the reactor will run until all fibers terminate.  An explicit\nchoice has been made to use\n[C11 threads](https://en.cppreference.com/w/c/thread)\nover pthreads.\n\nA new reactor will be initialized the first time `reactor_get` is called in\na particular thread; the underlying `io_uring` will attempt to pin itself to\none processor for which the thread has affinity.  The intention is to have\none io_uring running per thread, each pinned to one processor.\n\nFibers are created via `ucontext` but context-switching occurs via\n`sigsetjmp`/`siglongjmp` to avoid the `sigprocmask` system call.  It is not\nwise to modify the process signal mask after any fiber has been created,\nwhether or not it has run yet.\n\nOperations that can not be immediately submitted to the underlying\n`io_uring` will be deferred onto a wait-queue.  On completion, operations\nreturn to the calling fiber directly.  Thus, fibers are written procedurally\nbut will coöperatively context-switch during operations.  Error codes are\ntypically returned as negative values.\n\nOperations may be invoked outside of a fiber but may return prior to the\nreactor completing all pending work.  In that case, `reactor_runnable` will\nbe true and an invocation of `reactor_run` will be required to clear the\nwork.\n\nReactors can store a user-data `cookie` and an optional destructor via\n`reactor_cookie_jar`.  When the reactor is torn down, the cookie will be\neaten.\n\n## Examples\n * iou_cat --- moves bytes between one or more input streams and stdout\n * iou_dns --- resolve dns forward and reverse lookups asynchronously\n * iou_h2c --- toy HTTP/2 cleartext server on 8000, requires [libnghttp2](https://github.com/nghttp2/nghttp2)\n * iou_port7 --- TCP \u0026 UDP echo service, à la [port7](https://github.com/pallas/port7)\n * iou_timers --- use multiple timerfds to make some noise\n * iou_tls --- STDIN -\u003e TLS -\u003e STDOUT\n * iou_tlsd --- echo/TLS on 12345\n\n## Extra\n\nThis project is a toy, created out of a desire to better understand\n[io_uring](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/io_uring)\nand to atone for some of\n[liboco](https://github.com/pallas/liboco)'s\nsins.\n\nThanks to some wonderful resources, including\n * [Lord of the io_uring](https://unixism.net/loti/),\n * [Fibers, Oh My!](https://graphitemaster.github.io/fibers/),\n * [dankwiki](https://nick-black.com/dankwiki/index.php/Io_uring),\n * [Awesome io_uring](https://github.com/espoal/awesome-iouring),\n * [archlinux](https://man.archlinux.org/listing/extra/liburing/), \u0026\n * [LWN.net](https://lwn.net/).\n\nLicense: [MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpallas%2Fioucontext","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpallas%2Fioucontext","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpallas%2Fioucontext/lists"}