You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CHANGELOG.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,8 +10,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
10
10
### Added
11
11
- Makefile with `build`, `test`, `clean`, and `setup` targets wrapping CMake
12
12
- Re-verified current macOS aarch64 (Apple Silicon) support on Sequoia 15.7.3
13
-
-6 new test cases: `Memory` accessors, `getWriteFlags` logic, `std::span` write overloads, segment overwrite, queue capacity=1 edge case, `maxMessageSize` boundary
13
+
-New test case on `Memory` accessors, `getWriteFlags` logic, `std::span` write overloads, segment overwrite, queue capacity=1 edge case, `maxMessageSize` boundary and concurrent writing; also added docs to understand the tests better
14
14
-`.vscode/c_cpp_properties.json` for C++20 IntelliSense on macOS (arm64/aarch64)
15
+
- No-flake stability test: re-runs the full suite 1000 times as subprocesses to catch timing-dependent failures (cross-platform, skips itself via `LSM_NOFLAKE` env var)
16
+
- Added `macos-latest` to GitHub Actions CI matrix with `LSM_NOFLAKE=1` to skip the 1000-iteration flake test in CI
15
17
16
18
### Changed
17
19
- Improved README: added supported platforms table, building instructions, tightened examples and documentation
Copy file name to clipboardExpand all lines: README.md
+21-8Lines changed: 21 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# libsharedmemory
2
2
3
-
A lightweight, header-only C++20 library for inter-process communication via shared memory. Transfer data between isolated OS processes — or between modules written in different programming languages — with a simple, cross-platform API.
3
+
A lightweight, header-only C++20 library for inter-process communication via shared memory. Transfer data between isolated OS processes - or between modules written in different programming languages - with a simple, cross-platform API.
4
4
5
5
**Key capabilities:**
6
6
- Stream-based read/write transfer (`std::string`, `float*`, `double*`, scalars)
Copy `include/libsharedmemory/libsharedmemory.hpp` into your project's include path — it's a single header.
91
+
Copy `include/libsharedmemory/libsharedmemory.hpp` into your project's include path - it's a single header.
92
92
93
93
Alternatively, use `npm` for dependency management:
94
94
@@ -121,11 +121,24 @@ enum DataType {
121
121
122
122
`kMemoryChanged` flips odd/even to signal data changes, allowing continuous readers to detect every update.
123
123
124
-
## Limits
124
+
## Limits and Frequently Asked Questions
125
+
126
+
### Can I use this for cross-platform network communication?
127
+
128
+
No. **Endianness** is not handled. This is fine for local shared memory but requires attention if copying buffers to a network protocol.
129
+
130
+
### What about cross compiler compatibility?
131
+
132
+
**Cross-compiler** behavior for the binary memory layout is undefined. The library is designed for C++20 compliant compilers on the same platform. For cross-compiler or cross-language interoperability, you must ensure consistent data type sizes, alignment, and endianness.
133
+
134
+
### Can I use this with multiple writers?
135
+
136
+
Maybe for slow writers, **if you are lucky**.
137
+
**Concurrent writers**(`SharedMemoryWriteStream`) are currently not safely supported. `write()` performs 3 non-atomic `memcpy` calls (flags, size, data). Two threads writing to the same segment can interleave these operations, producing torn reads with mixed content or incorrect sizes. Use a single writer per segment or add external synchronization.
138
+
139
+
### Are multiple producers supported for `SharedMemoryQueue`?
125
140
126
-
-**Endianness** is not handled. This is fine for local shared memory but requires attention if copying buffers to a network protocol.
127
-
-**Cross-compiler** behavior for the binary memory layout is undefined.
128
-
-**SharedMemoryQueue** works best with a single producer. Multiple concurrent producers require external synchronization.
141
+
Not yet. `enqueue()` uses a non-atomic read-modify-write on the write index. Two threads calling `enqueue()` on the same queue will read the same slot index, overwrite each other's data, and advance the index only once - causing **message corruption** in testing (up to 45% on macOS 15.7, aarch64, Macbook Air M4, 1000 messages, 2 producers). Use a single producer per queue or add a mutex around `enqueue()`.
0 commit comments