{"id":15424534,"url":"https://github.com/nibanks/eventq","last_synced_at":"2025-04-19T16:07:56.597Z","repository":{"id":49800299,"uuid":"518156587","full_name":"nibanks/eventq","owner":"nibanks","description":"Explores the different platform execution models for IO.","archived":false,"fork":false,"pushed_at":"2022-08-27T16:52:26.000Z","size":78,"stargazers_count":17,"open_issues_count":2,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T09:51:15.087Z","etag":null,"topics":["cross-platform","io","network"],"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/nibanks.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}},"created_at":"2022-07-26T17:29:34.000Z","updated_at":"2024-11-26T15:26:55.000Z","dependencies_parsed_at":"2022-08-12T20:23:03.431Z","dependency_job_id":null,"html_url":"https://github.com/nibanks/eventq","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nibanks%2Feventq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nibanks%2Feventq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nibanks%2Feventq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nibanks%2Feventq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nibanks","download_url":"https://codeload.github.com/nibanks/eventq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249220841,"owners_count":21232421,"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":["cross-platform","io","network"],"created_at":"2024-10-01T17:47:23.798Z","updated_at":"2025-04-16T08:33:35.946Z","avatar_url":"https://github.com/nibanks.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# eventq\n\nExplores the different platform execution models for IO.\n\n[![Build](https://github.com/nibanks/eventq/actions/workflows/build.yml/badge.svg)](https://github.com/nibanks/eventq/actions/workflows/build.yml)\n\nThe \"main loop\" of the application layer looks like this:\n\n```c\nPLATFORM_THREAD(main_loop, context) {\n    printf(\"Main loop start\\n\");\n    app_state* state = (app_state*)context;\n    bool running = true;\n    eventq_cqe events[8];\n    while (running) {\n        uint32_t wait_time = platform_process_timers();\n        uint32_t count = eventq_dequeue(\u0026state-\u003equeue, events, 8, wait_time);\n        for (uint32_t i = 0; i \u003c count; ++i) {\n            if (eventq_cqe_get_type(\u0026events[i]) \u003c APP_EVENT_TYPE_START) {\n                platform_process_event(\u0026state-\u003equeue, \u0026events[i]);\n            } else {\n                switch ((APP_EVENT_TYPE)eventq_cqe_get_type(\u0026events[i])) {\n                ...\n                }\n            }\n        }\n        eventq_return(\u0026state-\u003equeue, count);\n    }\n    printf(\"Main loop end\\n\");\n    PLATFORM_THREAD_RETURN(0);\n}\n```\n\nFeel free to look at [eventq.h](./eventq.h) for the abstraction layers and [eventq.c](./eventq.c) for the application layer usage.\n\n## IO Completion Ports\n\n[IO Completion Ports](https://docs.microsoft.com/en-us/windows/win32/fileio/i-o-completion-ports), or IOCP, is the standard mechanism for asynchronous IO on Windows. Generally, it is used to return the completion of a previous asynchronous call made by the application.\n\nTo try it out, run the following (**on Windows**):\n\n```Bash\ngit clone --recursive https://github.com/nibanks/eventq.git\ncd eventq \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake -G 'Visual Studio 17 2022' -A x64 ..\ncmake --build .\n./Debug/eventq.exe\n```\n\n## ProcessSocketNotifications\n\n[ProcessSocketNotifications](https://docs.microsoft.com/en-us/windows/win32/api/winsock2/nf-winsock2-processsocketnotifications) (PSN for short) is a fairly new Windows socket API that allows for an epoll or kqueue like IO model. It also leverages IO completion ports, but is event driven instead of simply a completion of a previous call.\n\nTo try it out, run the following (**on Windows**):\n\n```Bash\ngit clone --recursive https://github.com/nibanks/eventq.git\ncd eventq \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake -G 'Visual Studio 17 2022' -A x64 -DUSE_PSN=on ..\ncmake --build .\n./Debug/eventq.exe\n```\n\n## epoll\n\n[epoll](https://man7.org/linux/man-pages/man7/epoll.7.html) is generally viewed as the industry standard way for handling asynchronous operations on not just socket, but all file descriptors, on Linux.\n\nTo try it out, run the following (**on Ubuntu**):\n\n```Bash\ngit clone --recursive https://github.com/nibanks/eventq.git\ncd eventq \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake -G 'Unix Makefiles' -A x64 ..\ncmake --build .\n./eventq\n```\n\n## liburing\n\n[liburing](https://github.com/axboe/liburing#readme) is a library built on top of [io_uring](https://kernel.dk/io_uring.pdf) which is a fairly new interface for creating shared ring buffers between kernel and user mode to reduce the number of syscalls required to operate on file descriptors, such as sockets.\n\nTo try it out, run the following (**on Ubuntu**):\n\n```Bash\nsudo apt-get install liburing-dev\ngit clone --recursive https://github.com/nibanks/eventq.git\ncd eventq \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake -G 'Unix Makefiles' -A x64 -DUSE_IO_URING=on ..\ncmake --build .\n./eventq\n```\n\n## kqueue\n\n[kqueue](https://man.openbsd.org/kqueue.2) is generally viewed as the industry standard way for handling asynchronous operations on not just socket, but all file descriptors, on FreeBSD or mac.\n\nTo try it out, run the following (**on macOS**):\n\n```Bash\ngit clone --recursive https://github.com/nibanks/eventq.git\ncd eventq \u0026\u0026 mkdir build \u0026\u0026 cd build\ncmake -G 'Unix Makefiles' -A x64 ..\ncmake --build .\n./eventq\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnibanks%2Feventq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnibanks%2Feventq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnibanks%2Feventq/lists"}