Skip to content

Commit 1ac5a5d

Browse files
committed
Update changelog for version 1.0.2.2 and add server-client shared memory test case
1 parent 2f305ea commit 1ac5a5d

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

CHANGELOG

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# v1.0.2.2 - 2025-10-04
2+
- Fixed size calculation in shared memory mapping to use reserved_info struct
3+
- Added server-client shared memory test case
4+
15
# v1.0.2.1 - 2025-10-01
26
- Fixed buffer wrap read logic to properly retry from wrapped position
37
- Improved reader behavior when encountering wrap jump markers

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.10)
22

3-
set(BUILD_VERSION 1.0.2.1)
3+
set(BUILD_VERSION 1.0.2.2)
44

55
project(slick_queue
66
VERSION ${BUILD_VERSION}

include/slick_queue/slick_queue.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ class SlickQueue {
336336
auto err = GetLastError();
337337
throw std::runtime_error("Failed to map shm. err=" + std::to_string(err));
338338
}
339-
size_ = *reinterpret_cast<uint32_t*>(reinterpret_cast<uint8_t*>(lpvMem) + sizeof(std::atomic_uint_fast64_t));
339+
size_ = *reinterpret_cast<uint32_t*>(reinterpret_cast<uint8_t*>(lpvMem) + sizeof(std::atomic<reserved_info>));
340340
mask_ = size_ - 1;
341341
BF_SZ = 64 + sizeof(slot) * size_ + sizeof(T) * size_;
342342
UnmapViewOfFile(lpvMem);

tests/shm_tests.cpp

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,39 @@ TEST_CASE( "Publish and read multiple - shm" ) {
7171
REQUIRE(read_cursor == 3);
7272
REQUIRE(*read.first == 23);
7373
}
74+
75+
TEST_CASE( "Server Client - shm" ) {
76+
SlickQueue<int> server(4, "sq_server_cleint");
77+
SlickQueue<int> client("sq_server_cleint");
78+
REQUIRE(client.size() == 4);
79+
80+
auto reserved = server.reserve();
81+
*server[reserved] = 5;
82+
server.publish(reserved);
83+
auto reserved1 = server.reserve();
84+
*server[reserved1] = 12;
85+
auto reserved2 = server.reserve();
86+
*server[reserved2] = 23;
87+
server.publish(reserved2);
88+
89+
uint64_t read_cursor = 0;
90+
auto read = client.read(read_cursor);
91+
REQUIRE( read.first != nullptr );
92+
REQUIRE( read_cursor == 1);
93+
REQUIRE( *read.first == 5);
94+
95+
read = client.read(read_cursor);
96+
REQUIRE( read.first == nullptr );
97+
REQUIRE( read_cursor == 1);
98+
99+
server.publish(reserved1);
100+
read = client.read(read_cursor);
101+
REQUIRE(read.first != nullptr);
102+
REQUIRE(read_cursor == 2);
103+
REQUIRE(*read.first == 12);
104+
105+
read = client.read(read_cursor);
106+
REQUIRE(read.first != nullptr);
107+
REQUIRE(read_cursor == 3);
108+
REQUIRE(*read.first == 23);
109+
}

0 commit comments

Comments
 (0)