{"id":20827233,"url":"https://github.com/raphiara/spms_ring","last_synced_at":"2025-05-07T21:03:40.312Z","repository":{"id":166122229,"uuid":"601570995","full_name":"RaphiaRa/spms_ring","owner":"RaphiaRa","description":"Single publisher multiple subscriber ring buffer written in C","archived":false,"fork":false,"pushed_at":"2025-02-11T19:39:30.000Z","size":70,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-07T21:03:32.891Z","etag":null,"topics":["c","inter-process-communication","ipc","library","lock-free","message-queue","publish-subscribe","queue","shared-memory"],"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/RaphiaRa.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-02-14T10:56:32.000Z","updated_at":"2025-02-11T19:39:34.000Z","dependencies_parsed_at":"2024-11-17T23:11:39.696Z","dependency_job_id":"cf9c5c4f-e497-45fc-852c-07223965c955","html_url":"https://github.com/RaphiaRa/spms_ring","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/RaphiaRa%2Fspms_ring","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphiaRa%2Fspms_ring/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphiaRa%2Fspms_ring/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaphiaRa%2Fspms_ring/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RaphiaRa","download_url":"https://codeload.github.com/RaphiaRa/spms_ring/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252954409,"owners_count":21830902,"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","inter-process-communication","ipc","library","lock-free","message-queue","publish-subscribe","queue","shared-memory"],"created_at":"2024-11-17T23:11:32.095Z","updated_at":"2025-05-07T21:03:40.284Z","avatar_url":"https://github.com/RaphiaRa.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# spms_ring\n## Single Publisher Multiple Subscribers Ring Buffer written in C11\n\n### Description\n`spms_ring` is a single publisher multiple subscriber ring buffer suitable for shared memory.\nThe publisher writes messages to the ring without being aware of the subscribers.\nWhen a subscriber reads a message, it is not removed from the ring and still can\nbe read by other subscribers. If a subscriber is not fast enough to read the messages, it will miss some of them.\n\nBesides the usual read and write functions, I wanted the ring to have the following features:\n- Timestamps can be added to the messages and subscribers can read from a specific timestamp on.\n- Messages can be marked as key messages (Like key frames in video streams) and\nsubscribers can jump to the next key message.\n- A zero copy API.\n- Optionally letting the subscriber wait for new messages if the ring is empty.\n\nCurrently only Linux and MacOS are fully supported. The wait for new messages feature is not implemented for Windows, but it should be easy to do so.\n\n### Build \u0026 run tests/examples\n\n```sh\ngit clone git@github.com:RaphiaRa/spms_ring.git\nmkdir spms_ring/build; cd spms_ring/build\ncmake ..\nmake\n```\n\nRun the tests with\n```sh\n./test_spms\n```\n\nRun the example publisher\n```sh\n./example pub\n```\n\nRun the example subscriber in one or multiple other terminals\n```sh\n./example sub\n```\n\n### Installation\n\nEither...\n- simply copy `spms.h` and `spms.c` into your project and include `spms.h` in your source files.\n- or use CMake's `add_subdirectory` to add `spms_ring` as a subdirectory to your project (This will add the `spms::spms` target to your project).\n\n### Basic Usage\n\nSetup the memory for the ring buffer and the publisher\n```c\nstruct spms_config config = {0};\nconfig.buf_length = 1024 * 1024; // buffer size\nconfig.msg_entries = 1024;       // max number of messages in the buffer\nsize_t needed_size = 0;\nspms_ring_mem_needed_size(\u0026config, \u0026needed_size);\nbuffer = calloc(1, needed_size);\nspms_pub *pub = NULL;\nspms_pub_create(\u0026pub, buffer, \u0026config);\n```\nWrite data to the ring\n```c\nspms_pub_write_msg(pub, data, data_len, NULL);\n```\n\nSetup the subscriber\n```c\nspms_sub *sub = NULL;\nspms_sub_create(\u0026sub, buffer);\n```\n\nRead data from the ring\n```c\nuint8_t data[1024];\nspms_sub_read_msg(sub, data, sizeof(data), NULL, 0);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphiara%2Fspms_ring","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraphiara%2Fspms_ring","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraphiara%2Fspms_ring/lists"}