https://github.com/mohammadrezaamani/bridge
This Universal Shared Memory Bridge enables communication between processes across different programming languages by providing a shared memory interface, facilitating efficient data exchange.
https://github.com/mohammadrezaamani/bridge
bridge c js python shared-memory
Last synced: 3 months ago
JSON representation
This Universal Shared Memory Bridge enables communication between processes across different programming languages by providing a shared memory interface, facilitating efficient data exchange.
- Host: GitHub
- URL: https://github.com/mohammadrezaamani/bridge
- Owner: MohammadrezaAmani
- Created: 2024-03-26T00:17:32.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2024-03-26T00:59:56.000Z (about 1 year ago)
- Last Synced: 2025-01-13T11:12:19.788Z (5 months ago)
- Topics: bridge, c, js, python, shared-memory
- Language: Python
- Homepage:
- Size: 2.64 MB
- Stars: 3
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Universal Shared Memory Bridge
\[Under Development\!\]
## Overview
This project demonstrates how to establish communication between different programming languages using shared memory. Shared memory provides a mechanism for inter-process communication (IPC) by allowing multiple processes, regardless of the programming language they are written in, to share a region of memory, enabling efficient data exchange between them.
## Components
1. **Shared Memory Library (`shared_memory`)**:
- Provides functions to create shared memory, write data to shared memory, and read data from shared memory.
- Implemented in a language-agnostic manner to be usable by different programming languages.
- Exposes a simple API for interacting with shared memory.2. **Language-Specific Bindings**:
- For each programming language, create language-specific bindings to the shared memory library.
- These bindings provide an interface for the programming language to call the shared memory functions.3. **Shared Library / Dynamic Link Library (DLL)**:
- Contains the core functionality for creating, writing to, and reading from shared memory.
- Implemented using a language that supports low-level memory manipulation, such as C or C++.## Usage
1. **Compilation**:
- Compile the shared library source code (`shared_memory.c` or `shared_memory.cpp`) to generate the shared library or DLL.
```bash
gcc -shared -fPIC -o shared_memory.so shared_memory.c
```- Ensure that the shared library/DLL is accessible to all programming languages that will use it.
2. **Language-Specific Usage**:
- Import or include the language-specific bindings in your code.
- Use the provided functions in the bindings to interact with shared memory, create, write to, and read from shared memory.3. **Data Exchange**:
- Use the shared memory functions to exchange data between processes written in different programming languages.
- Data written to shared memory by one process can be read by another process, regardless of the language they are written in.## Example
An example usage scenario is provided where a Python script produces data at regular intervals, writes it to shared memory. Then, a Node.js script consumes the data from shared memory and logs it. Similarly, a C++ program can read the data from shared memory and perform some processing on it.
## Dependencies
- For the shared library:
- A language that supports low-level memory manipulation (e.g., C or C++)
- For language-specific bindings:
- Libraries or tools for generating bindings (e.g., `ctypes` for Python, `ffi-napi` for Node.js)
- For each programming language:
- Language-specific dependencies for calling external functions and interacting with shared memory