{"id":26167497,"url":"https://github.com/raftlib/ipc","last_synced_at":"2025-04-14T17:43:35.508Z","repository":{"id":40362834,"uuid":"392801478","full_name":"RaftLib/ipc","owner":"RaftLib","description":"Inter-process C++ communication library to enable allocation managed between processes/threads and send/receive of allocated regions between producers/consumer processes or threads using this IPC buffer.  (and yes it implements an M:N ring buffer too)","archived":false,"fork":false,"pushed_at":"2022-07-31T15:42:39.000Z","size":479,"stargazers_count":12,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-14T17:43:31.286Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C++","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/RaftLib.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":"2021-08-04T19:13:41.000Z","updated_at":"2025-01-26T21:18:44.000Z","dependencies_parsed_at":"2022-08-19T15:31:11.033Z","dependency_job_id":null,"html_url":"https://github.com/RaftLib/ipc","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/RaftLib%2Fipc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaftLib%2Fipc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaftLib%2Fipc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/RaftLib%2Fipc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/RaftLib","download_url":"https://codeload.github.com/RaftLib/ipc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248930062,"owners_count":21184944,"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":[],"created_at":"2025-03-11T17:37:55.601Z","updated_at":"2025-04-14T17:43:35.467Z","avatar_url":"https://github.com/RaftLib.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ABOUT\n\nThis is a relatively simple IPC buffer that allows multiple processes\nand threads to share a dynamic heap allocator, designate \"channels\"\nbetween processes, and share that memory between producer/consumer \npairs on those channels. \n\nCurrently implemented is the following:\n- multi-threaded/multi-process allocation via priority heap\n- per-thread TLS lock-free allocation slab\n- single-producer, single-consumer channel (multi-process and multi-threaded)\n- multiple channels per buffer (you can have as many independent channels as\nyou want till you run out of memory).\n- named static shared memory segment (as a channel) which can be used for synchronization or other purposes where message passing semantics aren't useful. \n\n## Status - [![CI](https://github.com/RaftLib/ipc/actions/workflows/main.yml/badge.svg)](https://github.com/RaftLib/ipc/actions/workflows/main.yml)\nCurrently testing the following combinations\n- Linux\n  - POSIX SHM + POSIX Semaphores\n  - POSIX SHM + SystemV Semaphors\n  - SystemV SHM + POSIX Semaphores\n  - SystemV SHM + SystemV Semaphors\n- OS X\n  - POSIX SHM + SystemV Semaphores\n  \n\n\n\n## Why\n* Lack of existing simple point-to-point multi-process\nallocation and communication mechanisms. \n\n## Simple example\n```cpp\n/** only include file you should need **/\n#include \u003cbuffer\u003e\n\n/**\n * shared memory buffer allocated and returned as a pointer,\n * this function can be called from each process safely to get\n * the file descriptor opened and memory opened within your \n * address space. \n */\nauto *buffer = ipc::buffer::initialize( \"thehandle\"  );\n\n/** get a thread local data structure for the buffer with thread id **/\nauto *tls_producer      = ipc::buffer::get_tls_structure( buffer,\n                                                          thread_id );\nconst auto channel_id = 1;\n/**\n * allocate a channel that is a single-producer, single consumer\n * record channel, record channels are used for larger allocations\n * up to 1MiB. The consumer must know that channel_id is the correct\n * channel and also the type of channel otherwise an error will be \n * thrown. \n */\nipc::buffer::add_spsc_lf_record_channel( tls_producer, channel_id )\n\n/** get some memory and do something with it **/\nint *output = (int*)\n/** currently single allocations limited to 1MiB **/\nipc::buffer::allocate_record( tls_producer, \n                              sizeof( int ), \n                              channel_id );\n\n/** lock-free record send **/\nwhile( ipc::buffer::send_record( tls_producer, \n                                 channel_id, \n                                 (void**)\u0026output ) \n                                 != ipc::tx_success );\n\n//NOTE: consumer side has equiv lock-free receive record\n\n/** close tls **/\nipc::buffer::close_tls_structure( tls_producer );\n\n/** destroy the buffer **/\nipc::buffer::destruct( buffer       /** buffer ptr  **/, \n                       \"thehandle\"  /** file handle **/, \n                       true         /** unlink, true if you're the last user **/);\n```\n\n# Compiling\n\nCurrently only for Linux and OS X systems. Will add Windows \nsoon. Compiles with gcc 9+ and clang 10+. \n\n```\ngit clone https://github.com/RaftLib/ipc.git\ncd ipc\ncmake ../ \nmake -j\nmake test\n```\n\n# Usage notes\nWill add more notes soon. Most complete example with two \nprocesses and two threads (1 process communicating with \nanother process that has two threads) is [here](https://github.com/RaftLib/ipc/blob/main/testsuite/spsc_two_processes_multi_channel.cpp)\n\n- NOTE: the combination of OS X + SystemV Shared Memory + SystemV Semaphores is currently \nnot passing tests, will investigate. All other combinations on OS X and Linux work. \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraftlib%2Fipc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fraftlib%2Fipc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fraftlib%2Fipc/lists"}